August 2014
Intermediate to advanced
120 pages
2h 45m
English
One of the least complex (but most-used) macros in Clojure is comment, which entirely avoids evaluating the code contained in it:
| context/comment.clj | |
| | (defmacro comment |
| | "Ignores body, yields nil" |
| | {:added "1.0"} |
| | [& body]) |
| | |
| | (comment |
| | (println "wow") |
| | (println "this macro is incredible")) |
| | ;=> nil |
| | |
| | (+ 1 2) ; this is another type of comment |
| | (+ 1 2) #_(println "this is yet another") |
There are a couple of other commenting mechanisms in Clojure, but comment is the only one that’s a macro (the others are built into the Clojure reader). The return value of comment is always nil, and none of the code passed to it is ever evaluated. Since it’s a macro, the code passed in ...
Read now
Unlock full access