3 ms·
They are subtly different. Macros are the only way to process s-expressions without first calling eval on them. This is necessary because without macros you cou
by fsmv 1y ago
They are subtly different. Macros are the only way to process s-expressions without first calling eval on them. This is necessary because without macros you could only generate and eval quoted code. Also practically it's cumbersome to work with everything being quoted when writing lisp code generators.
Without macros you could implement eval still but your internal lisp implementation could only work on quoted s-expressions, there would be no way to get back to the base unquoted level of lisp code (assuming you can't use the primitive eval, since you're trying to implement lisp in lisp).
Another use case is implementing a shortcutting boolean and function. You can't do the shortcutting without macros because all of the arguments get eval'd before passing to your and function.