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 ...

Get Clojure Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.