summaryrefslogtreecommitdiff
path: root/topics/lisp/macros.gmi
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-07-05 10:39:45 +0300
committerMunyoki Kilyungi2023-07-05 10:39:45 +0300
commit45f75288f1144077133bc03df66b85d6718b22f8 (patch)
treef2c9f73f86ee58b3f6a5cbd7f0ab64b524db6a28 /topics/lisp/macros.gmi
parentb5113dc72a27d2c20432e46c80f8110eb25dbc45 (diff)
downloadgn-gemtext-45f75288f1144077133bc03df66b85d6718b22f8.tar.gz
Add some rough notes about macros
Diffstat (limited to 'topics/lisp/macros.gmi')
-rw-r--r--topics/lisp/macros.gmi9
1 files changed, 9 insertions, 0 deletions
diff --git a/topics/lisp/macros.gmi b/topics/lisp/macros.gmi
new file mode 100644
index 0000000..dd8634b
--- /dev/null
+++ b/topics/lisp/macros.gmi
@@ -0,0 +1,9 @@
+# Scheme Macros
+
+* If a pattern variable appears within an ellipsis prototype in the pattern, it cannot appear outside an ellipsis prototype in the template.
+* syntax-case macros are procedural syntax transformers. The syntax-case expressions provide a way to destructure a syntax object, and to rebuild syntax objects as output. Simply put, they are a way to take apart and put together program text, and to be a valid syntax-transformer, they need to be wrapped in a procedure.
+* syntax-case macros transform syntax objects, not raw Scheme forms. Instead of representing syntax objects as symbols, the syntax expander represents identifiers as annotated syntax objects, attaching such information to those syntax objects as is needed to maintain referential transparency.
+* A syntax transformer procedure must return a syntax object.
+* Within a syntax expression, any appearance of a pattern variable is substituted into the resulting syntax object, carrying with it all relevant metadata from the source expression, such as lexical identity and source location.
+* A pattern variable may only be referenced from inside a syntax form.
+* syntax-case creates procedural macros, giving the full power of Scheme to the macro expander.