3 ms·
A reader macro is not a kind of macros [0]. It is a way to customize the Lisp reader by associating a custom function to an entry in the readtable. So you can
by junke 10y ago
A reader macro is not a kind of macros [0].
It is a way to customize the Lisp reader by associating a custom function to an entry in the readtable.
So you can say that character '[' will be tied to a custom reader function, which reads from a stream and produces a Lisp object, at readtime.
The standard sharpsign[1] character is used to read different kind of structures: complex numbers #C(0 1), structs #S(tree :left nil :right nil), and so on.
In particular, you can have sharpsign-dot, which reads a lisp form, evaluates it at read time; the result is the form being read.
Also, you can use #1= and #1# to affect parts of your code to reader variables and reuse them in other places.
If the PRINT-CIRCLE (there are earmuffs around it, but I can't format it here) variable is set to true, here is a quine:
#1=(print '#1#)
[0] http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_r.htm#reader_macro http://www.lispworks.com/documentation/HyperSpec/Body/26_glo...
[1] http://www.lispworks.com/documentation/HyperSpec/Body/02_dh.htm http://www.lispworks.com/documentation/HyperSpec/Body/02_dh....