Created
December 1, 2012 11:03
-
-
Save abp/4181529 to your computer and use it in GitHub Desktop.
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
(defn unresolvable-syms [form] | |
(let [usyms (atom #{}) | |
_ (postwalk | |
#(do | |
(when (and (symbol? %) (nil? (resolve %))) | |
(swap! usyms conj %)) | |
%) form)] | |
@usyms)) | |
(defmacro exk [& args] | |
"[name? doc? attr-map? prepost-map? body]" | |
(let [{:keys [body] :as fn-decl} (args->fn-decl args) | |
_ (when-not (nil? (:args fn-decl)) | |
(throw (Throwable. "exk takes no args."))) | |
(fnk* | |
(fn-decl->fnk-decl | |
(assoc fn-decl :args (vec (unresolvable-syms body))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment