我有记录(defrecord Rec [id])
我和它一起工作
(def my ( Rec. 2 ))
(println (:id my))
现在我想用宏替换记录定义。这样我就可以写
(r 2)
(println (:id my))
我写了宏
(defmacro r [id]
(list 'def 'my (symbol "(") 'Rec. id (symbol ")")))
我用macroexpand检查了它
(macroexpand-1 '(r 2)) => (def my ( Rec. 2 ))
但我RuntimeException: Too many arguments to def
继续(r 2)
。