(macroexpand-1 form)
(macroexpand-1 form env)
If form represents a macro form or an inlineable function,returns its expansion,
else returns form.
Source
(defn macroexpand-1
"If form represents a macro form or an inlineable function,returns its expansion,
else returns form."
([form] (macroexpand-1 form (empty-env)))
([form env]
(env/ensure (global-env)
(cond
(seq? form)
(let [[op & args] form]
(if (specials op)
form
(let [v (resolve-sym op env)
m (meta v)
local? (-> env :locals (get op))
macro? (and (not local?) (:macro m)) ;; locals shadow macros
inline-arities-f (:inline-arities m)
inline? (and (not local?)
(or (not inline-arities-f)
(inline-arities-f (count args)))
(:inline m))
t (:tag m)]
(cond
macro?
(let [res (apply v form (:locals env) (rest form))] ; (m &form &env & args)
(update-ns-map!)
(if (obj? res)
(vary-meta res merge (meta form))
res))
inline?
(let [res (apply inline? args)]
(update-ns-map!)
(if (obj? res)
(vary-meta res merge
(and t {:tag t})
(meta form))
res))
:else
(desugar-host-expr form env)))))
(symbol? form)
(desugar-symbol form env)
:else
form))))