Browse Clojure Foundations for Java Developers

Macros

What macros are, what they expand to, and how to read them safely.

Macros are functions that run at macro-expansion time and return Clojure code (data) that becomes part of your program. They let Clojure introduce new syntactic forms—things that look like language features.

For Java engineers, a useful analogy is “compile-time transformation,” but with direct access to the program’s syntax.

The discipline is simple:

  • Prefer a function first.
  • Write a macro only when you need to control evaluation, introduce bindings, or create a small DSL.
  • Use macroexpand-1 early and often to see what your macro really generates.

In this section

Revised on Friday, April 24, 2026