Taxonomy of Macros

Now that you have written several macros, we can restate the rules of Macro Club with more supporting detail.

The first rule of Macro Club is Don’t Write Macros. Macros are complex. If none of the macros in Clojure seems complex to you, my company is hiring.[56]

The second rule of Macro Club is Write Macros If That Is the Only Way to Encapsulate a Pattern. As you have seen, the patterns that resist encapsulation tend to arise around special forms, which are irregularities in a language. So, the second rule can also be called the Special Form Rule.

Special forms have special powers that you, the programmer, do not have:

  • Special forms provide the most basic flow control structures, such as if and recur. All flow control ...

Get Programming Clojure, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.