Lisp Macros - Pond’ring Aloud
2025-03-18
In Lisp, there are only 3 kinds[+] of things
functions
atoms
macros.
Macros look like functions. A table in the compiler differentiates between macros and functions.
With these imaginary definitions...
defmacro m2 (x) = m1 (x)
defmacro m1 (x) = f(x)
deffunction f (x) = ...
evaluate the following code:
f (41)
m2 (42)
f (43)
Macro expand ---->
f (41)
m1 (42)
f (43)
Re-expand, from where we left off ---- >
f (41)
f (42)
f (43)
The Lisp evaluator repeatedly expands macros until only functions (and atoms) remain. Then, it evaluates the program.
[+] This is not quite true, but, is a good enough approximation for this article.
See Also
Email: ptcomputingsimplicity@gmail.com
References: https://guitarvydas.github.io/2024/01/06/References.html
Blog: guitarvydas.github.io
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/65YZUh6Jpq
Leanpub: [WIP] https://leanpub.com/u/paul-tarvydas
Gumroad: tarvydas.gumroad.com
Twitter: @paul_tarvydas
Substack: paultarvydas.substack.com

