|"If anyone has good examples of macros that can't be expressed with a convenient notation for closures, it would be interesting to see them. My Smalltalk-hacking friend Trevor Blackwell has often claimed that macros were unnecessary if you had blocks."|
Trevor Blackwell's provocative post about places to avoid macros, and a summary of a lot of the examples in the thread:
Its responses are good too. I would be careful using macros for them, but not avoid them entirely. See arc's obj and fallintothis's inittab (http://arclanguage.org/item?id=11187)
"have all the examples of potentially non-blockable macros so far been cases
of punning, treating something as both code and data?"
(if (not test) (assert-error (quote test))))))
Guy Steele's symbolic-differentiation macro:
Reference to how you would do that in smalltalk, but it tellingly doesn't have code:
Three interesting-looking papers from 1984:
Interesting back-story on common lisp's LOOP:
A tantalizing reference to the language-vs-tool tension:
Guy Steele (referring to the assert macro): "Macros let me express the idea that I need only a few relevant line numbers kept around at run time, rather than all of them."
Trevor Blackwell: "I don't believe in adding a complex language feature for small runtime
Meta-programming as code generation vs meta programming as parameterized higher-order functions:
Avi Bryant dissing all before him: "Now, I know there are better examples out there, I just want somebody to bring them up. The best I can do right now is the typical with-html
macros people use for generating markup - I've never been able to
satisfactorily replace those in Smalltalk or Ruby."
Finally, Guy Steele echoing PG's opinion on brevity:
Reading all this, my conclusion is that if you don't care as much about terseness (like Trevor Blackwell) you probably won't have as much use for macros.
Parent thread that spawned this one: