How to reuse a macro like a function

Having fun discovering how things work and why they're here.

Thoughtfull Systems

@technosophist

If you're doing this inside a macro then you have &form and &env available, so you can just pass them through directly.

Also, fun fact: vars called as functions automatically deref themselves, so you don't need an @ for them.

With both these changes, the code becomes:

(defmacro defn+ [& args]
(let [[_def name [_fn & arities]] (apply #'defn &form &env args)
improved-arities (improve-the-arities arities)]
`(def ~name (fn ~@improved-arities))))