Given a function object or name, how can I determine its arity? Something like (arity func-name) .
(arity func-name)
I hope there is a way, since arity is pretty central in C
Actually it also works on macros:
(defn arg-count [f] (let [m (first (.getDeclaredMethods (class f))) p (.getParameterTypes m)] (alength p))) (defmacro my-macro []) (arg-count @#'my-macro) ; 2
Why 2? Because every macro has two implicit arguments &form and &env respectively.
&form
&env