I am trying to write a macro that redirects a call to the function that does it. It is a way to collect all published functions into a top-level clj file. https://martinfowler.com/bliki/PublishedInterface.html
I want to copy the doc string and arglists, and the docstring works fine, but not the argslists. What am I missing?
(defmacro idef
[fname]
(let [sym (symbol (str "clojure.core/" fname))
metas (meta (find-var sym))
arglists (:arglists metas)
doc (:doc metas)]
;;`(def ~(with-meta fname {:doc doc :arglists arglists}))
`(def ~(with-meta fname {:doc doc})
~sym)))
(idef inc)
If I use the commented line instead, I get
CompilerException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector, compiling:(interface.clj:22:1)
This is just a sample where the namespace is hardcoded to clojure core.
This question is really similar, but you see I have no problem copying the :doc part, what is to special about :arglists
Help me write a Clojure macro which automatically adds metadata to a function definition