4 ms·
I 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 sy
by fpoling 6y ago
I 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.