Last active
August 29, 2015 14:17
-
-
Save tclamb/a599302beb39677f43f7 to your computer and use it in GitHub Desktop.
defn, but with source and env attached for introspection
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 defn* | |
"Like clojure.core/defn, with the function definition in :source metadata and env in :env metadata." | |
{:arglists (:arglists (meta #'defn))} | |
[f & xs] | |
`(defn ~(with-meta f (assoc (meta f) | |
:source `(quote ~&form) | |
:env `(zipmap (quote ~(keys &env)) | |
(list ~@(keys &env))))) | |
~@xs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment