Chapter 4. Metaprogramming with Macros
Programmers often stumble into situations where they would like to add features or constructs to their programming language of choice. Generally, if a feature would have to be added to a language, the language's compiler or interpreter would need some modification. Alternatively, Clojure (and other Lisps as well) uses macros to solve this problem. The term metaprogramming is used to describe the ability to generate or manipulate a program's source code by using another program. Macros are a metaprogramming tool that allow programmers to easily add new features to their programming language.
Lisps are not the only languages with support for macro-based metaprogramming. For example, in C and C++, macros are handled by the compiler's preprocessor. In these languages, before a program is compiled, all macro calls in the program's source code are replaced by their definitions. In this sense, macros are used to generate code...