Suppose I'm trying to write a macro that can create a list of :tag
metadata attributes (ex: Java type hints) for a given vector of symbols. Consider the following REPL session:
(def ^String x nil)
(def ^Integer y nil)
(def ^Long z nil)
(defmacro all-tags [items]
(vec (for [item items]
`(:tag (meta (resolve (quote ~item)))))))
; this works fine
(all-tags [x y z])
[java.lang.String java.lang.Integer java.lang.Long]
; however, if I instead have a symbol that refers to this list, it fails
(def myargs [x y z])
(all-tags myargs)
Syntax error macroexpanding all-tags at (form-init2442452721395147632.clj:1:1).
Don't know how to create ISeq from: clojure.lang.Symbol
How can I rewrite the all-tags
macro to handle the second case, such that it returns the same result as the first case?