Skip to content

Instantly share code, notes, and snippets.

@tclamb
Last active August 29, 2015 14:17
Show Gist options
  • Save tclamb/a599302beb39677f43f7 to your computer and use it in GitHub Desktop.
Save tclamb/a599302beb39677f43f7 to your computer and use it in GitHub Desktop.
defn, but with source and env attached for introspection
(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