9. Simplifying Logging with a Macro

One of the distinguishing characteristics of a Lisp-language like Clojure is the parenthesis. The benefit of this is minimal syntax, where everything is a list. Xerox Parc alumni and Apple Fellow Alan Kay called this characteristic a homoiconic language. In addition to simple syntax, we can treat code as data and data as code. One of the primary means to treat code as data is a macro.

In this chapter we’ll give you some examples of how you can use macros in your day-to-day work. We’ll start with a logging application and then look at a more advanced use in the next chapter. Note that there are better ways to achieve both these goals in Clojure, and we’ll mention those as well. The point is being able to recognize ...

Get Clojure Recipes now with O’Reilly online learning.

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