January 2017
Intermediate to advanced
565 pages
13h 46m
English
Do you want to know when it is that macros are used extensively? Think about defn; what's more, do this:
(macroexpand-1 '(defn sample [a] (println a))) ;; (def sample (clojure.core/fn ([a] (println a))))
Did you know that defn is a macro in clojure.core that creates a function and binds it to a var in the current namespace?
Clojure is filled with macros; if you want some samples, you can look at Clojure core, but what else can you do with macros?
Let's have a look at some interesting libraries:
yesql: The yesql library is a very interesting sample of code generation. It reads SQL code from a SQL file and generates the Clojure functions accordingly. Look for the defquery and defqueries macros in the yesql project on GitHub; ...Read now
Unlock full access