Created
January 19, 2012 22:13
-
-
Save tavisrudd/1643214 to your computer and use it in GitHub Desktop.
add metadata to clojure multifn methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defmethod | |
"Creates and installs a new method of multimethod associated with dispatch-value. " | |
{:added "1.0"} | |
[multifn dispatch-val & fn-tail] | |
`(. ~(with-meta multifn {:tag 'clojure.lang.MultiFn}) addMethod ~dispatch-val (fn ~@fn-tail))) | |
(defmacro defmethod-with-metadata | |
"Creates and installs a new method of multimethod associated with dispatch-value. " | |
{:added "1.0"} | |
[multifn dispatch-val & fn-tail] | |
`(. ~(with-meta multifn {:tag 'clojure.lang.MultiFn}) | |
addMethod | |
~dispatch-val | |
(with-meta (fn ~@fn-tail) | |
~{:ns *ns* | |
:arglists (list 'quote (list (vec (first fn-tail)))) | |
:name (name multifn) | |
:line (:line (meta &form)) | |
:file *file*}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment