假设我要编写一个可以创建具有:tag
元数据属性列表(例如Java类型提示)的宏,针对给定的符号向量。考虑以下REPL会话
(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
如何重写all-tags
宏以处理第二种情况,使其与第一种情况返回相同的结果?