
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 0.49 KB | hits: 7 | expires: Never
(in-ns 'user)
;; An alternate `defmacro2` definition based on the example from
;; "Macros are Hard" presentation by @david_mcneil. This
;; implementation defines a macro called `name` and a function
;; equivalent called `name+` which still evaluates at compile time as
;; opposed to execution time
(defmacro defmacro2 [name args & body]
`(do
(defmacro ~name ~args ~@body)
(defn ~(symbol (str name "+")) [~@args]
(~name ~@args))))
(defmacro2 foo [a b] `(+ ~a ~b))
(foo+ 1 2)