expression #(meta #'%) is a macro that extends to defn (actually def ), which has a parameter called p1__1637 # that was created using gensym , and a meta call on the one that is trying to use this local parameter like var, since var does not exist with this name, you get this error.
If you start with the var vector instead of the function vector , then you can just overlay the meta on them. You can use the var variable (almost) anywhere you would use a function with very little cost when you search for the contents of var every time it is called.
user> (def vector-of-functions [+ - *]) #'user/vector-of-functions user> (def vector-of-symbols [#'+ #'- #'*]) #'user/vector-of-symbols user> (map #(% 1 2) vector-of-functions) (3 -1 2) user> (map #(% 1 2) vector-of-symbols) (3 -1 2) user> (map #(:name (meta %)) vector-of-symbols) (+ - *) user>
so adding a #' pair to your source code and removing the extra trailing: should do the trick:
user> (defn #^{:tau-or-pi :pi} funca "doc for func a" {:ans 42} [x] (* xx)) #'user/funca user> (defn #^{:tau-or-pi :tau} funcb "doc for func b" {:ans 43} [x] (* xxx)) #'user/funcb user> (def funcs [#'funca #'funcb]) #'user/funcs user> (map #(meta %) funcs) ({:arglists ([x]), :ns #<Namespace user>, :name funca, :ans 42, :tau-or-pi :pi, :doc "doc for func a", :line 1, :file "NO_SOURCE_PATH"} {:arglists ([x]), :ns #<Namespace user>, :name funcb, :ans 43, :tau-or-pi :tau, :doc "doc for func b", :line 1, :file "NO_SOURCE_PATH"}) user> (map #(:tau-or-pi (meta %)) funcs) (:pi :tau) user>
Arthur ulfeldt
source share