Taxonomy of Macros

Now that you’ve 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 you can avoid that complexity, you should.

The second rule of Macro Club is, Write Macros If That Is the Only Way to Encapsulate a Pattern. As you’ve 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 macros must eventually call a special ...

Get Programming Clojure, 3rd 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.