Evaluating Your First Macro

In order to think about how macros work, it’s useful to picture a ladder like the one in the figure that follows this paragraph. When we take a step up this ladder, we’re shifting from thinking in code to thinking in data, and when we step back down the ladder, we’re shifting from data back to code. In this world, when we encounter a macro call in a piece of code, we’ll think of it just like a function, but one that operates one level up the macro ladder, on unevaluated code rather than on evaluated data. When we need to expand a macro, we’ll step up the ladder, and once we’re done expanding it, we’ll step back down (with the expanded expression in our pocket). This is a simplification, but it’s a good enough way to ...

Get Mastering Clojure Macros 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.