Define a symbol macro. Because symbol macros are not part of
Clojure's built-in macro expansion system, they can be used only
inside a with-symbol-macros form.
(defmacro defsymbolmacro
"Define a symbol macro. Because symbol macros are not part of
Clojure's built-in macro expansion system, they can be used only
inside a with-symbol-macros form."
[symbol expansion]
(let [meta-map (if (meta symbol) (meta symbol) {})
meta-map (assoc meta-map :symbol-macro true)]
`(def ~(with-meta symbol meta-map) (quote ~expansion))))
Comments top
No comments for defsymbolmacro. Log in to add a comment.