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 description; it's time to bring you upto speed.
First, the defmacro
routine requires a name and some parameters. There you go, we give it the name my-very-first-macro
and, being a bit on the greedy side, no parameter whatsoever.
Now to...