January 2014
Intermediate to advanced
232 pages
5h 11m
English
Clojure, being a Lisp, also provides a powerful macro system. Macros allow templating repetitive blocks of code and deferring evaluation, among numerous other uses. A macro works by treating code as data instead of evaluating it. This allows us to manipulate the code tree just like any other data structure.
Macros execute before compile time and the compiler sees whatever the result of executing the macro will be. Because of this level of indirection, macros can be difficult to reason about, and thus it’s best not to use them when a function will do the job.
However, there are legitimate uses for macros, and it’s worth understanding how they work. In this book we use very few macros, so we’ll only touch ...
Read now
Unlock full access