1. Bending Clojure to your Will:
Macros and Domain Specific
Languages
CUFP - Boston, 2013
Leonardo Borges
@leonardo_borges
www.leonardoborges.com
www.thoughtworks.com
Thursday, 19 September 13
12. •Data is code is data
•Programs that write programs
•Magic happens at macro-expansion time
•Most control structures in Clojure are built out of macros
But what are macros?
Thursday, 19 September 13
14. Macro-expansion time
(arg-logger
(+ 2 3))
Every usage of a macro
(do (+ 2 3))
Gets replaced with its expansion
prior to compilation
Thursday, 19 September 13
26. Jam time!
•Get the code - http://bit.ly/cufp-2013-macros
•Make sure you have leiningen 2.x installed
•Run $lein midje or lein midje :autotest from the project root
•Watch the tests fail!
•Fix them :)
Thursday, 19 September 13