O'Reilly logo

Clojure Programming Cookbook by Nicolas Modrzyk, Makoto Hashimoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining simple macros

Macros in Clojure allow you to redefine the processing flow and generate code through a simple but very Clojure-esque defmacro construct.

This section will guide us through writing some of those building blocks and reading some macro code from the original from Clojure.

Getting ready

Macro-biotics and a spoon are all you need for this recipe. No other agricultural produce required.

How to do it...

All you ever wanted to know about writing simple Clojure macros is in this section. Keep on writing those simple macros until it finally makes sense.

Your first macro

Well, here you go. Your first macro is here:

(defmacro my-very-first-macro []  
  (list println "FIRST")) 

Okay, that was kind of a fast introduction to something that deserves ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required