3 ms·
"Even Lisp ended up with macros with own sub language..." I assume you're talking about Scheme approaches like `syntax-case` and `syntax-rules`? In Common Lis
by gmfawcett 6y ago
"Even Lisp ended up with macros with own sub language..." I assume you're talking about Scheme approaches like `syntax-case` and `syntax-rules`? In Common Lisp, macros are written in Lisp, the same way you would write runtime code. Unquoting and splicing are part of the core language (e.g. they can be applied to data as well as to code).
- fpoling 6y agoI was not aware that unquoting in Common Lisp can be applied to data. So it is not a specialized sub language just for macros, but a general purpose template system that could also generate code.
- kazinator 6y agoThat's right. There is no difference between: (defmacro my-quote (x) `(quote ,x)) and (defmacro my-quote (x) (list 'quote x)) That `(quote ,x) is just way of writing (list 'quote x), not a notation for writing macros. That's it.
- ywei3410 6y agoIt's really a shorthand for writing lists - sexp's are lists, so can use the same syntax. Macro's in Lisp are essentially "just" functions where the arguments are un-evaluated - you can use all the same functions etc... Writing a simple Lisp interpreter is really quite educational - when you add macros and quoting into the language, you suddenly have a realisation at how simple it is.