Is there a way to get metadata for function arguments in clojure? The answer posed in this question does not actually work at all:
user> (defn foo "informative dox!" [] 1) #'user/foo user> (defmacro get-docs [func] `(:doc (meta (var ~func)))) #'user/get-docs user> (get-docs foo) "informative dox!" user> (get-docs (identity foo)) ; Evaluation aborted. user> (defn process-docs [f] (let [docs (get-docs f)] (reverse docs))) ; Evaluation aborted.
The second line does not work because you cannot call var in the list (identity foo) , and the last line does not even compile, because the compiler complains about the impossibility of solving f .
Most of the solutions to this problem that I found rely on the idea that you have access to a character in a function definition or something like that so you can do something like (resolve 'f) or (var f) . But I want something that I can use for function arguments, where you do not know this information.
Essentially, I would like to express an expression that can be substituted for the question marks below to get the #'map metadata:
(let [x map] (??? x))
ben w source share