Wilfred Hughes has an interesting post, Comparitive Macrology, in which he looks at the macro systems of various languages. For each, he implements two macros:
- A
swap
macro to exercise hygiene - An anaphoric macro to exercise (intentional) variable capture
He demonstrates the advantages and disadvantages of each language’s macro system.
Hughes starts with C, moves on to Common Lisp, New Lisp, Scheme, Clojure, sweet.js, Rust, and Julia. It’s a really interesting post and well worth reading.
One of the things that struck me was how ugly the syntax of the non-Common Lisp languages are. Even Scheme, which shares most of its syntax with Common Lisp has a really ugly macro language. That’s something worth remembering the next time non-Lispers start grousing about all those parentheses. Just refer them to the syntax of their language.
UPDATE: Wilford → Wilfred