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