Skip to content

Instantly share code, notes, and snippets.

@abp
Created December 1, 2012 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abp/4181529 to your computer and use it in GitHub Desktop.
Save abp/4181529 to your computer and use it in GitHub Desktop.
(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