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