Reader Macros

Clojure forms are read by the reader, which converts text into Clojure data structures. In addition to the basic forms, the Clojure reader also recognizes a set of reader macros.[19] Reader macros are special reader behaviors triggered by prefix macro characters.

The most familiar reader macro is the comment. The macro character that triggers a comment is the semicolon (;), and the special reader behavior is “ignore everything else up to the end of this line.”

Reader macros are abbreviations of longer list forms and are used to reduce clutter. You have already seen one of these. The quote character () prevents evaluation:

 ​'(1 2)​
 ​-> (1 2)​

’(1 2) is equivalent to the longer (quote (1 2)):

 ​(quote (1 2))​
 ​-> (1 2)​

The ...

Get Programming Clojure, 2nd Edition 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.