【发布时间】:2013-02-27 02:44:03
【问题描述】:
我对如何评估传递给宏的参数有疑问,详情如下。
定义了这个宏
(defmacro test-macro (xlist)
`(* ,@xlist))
还有这个全局变量(defvar *test-list* '(1 100 2 200))。
当*test-list*被传递给这个宏(test-macro *test-list*)时,会返回这个错误——
value *TEST-LIST* is not of the expected type LIST.
[Condition of type TYPE-ERROR]
但是如果函数修改成这个,则返回列表
(defmacro test-macro (xlist)
`(,@xlist)) ;; removed the * operator
(test-macro *test-list*) 将返回 (1 100 2 200)。
所以我怀疑为什么,@xlist 在第一种情况下没有得到评估,即在应用* 运算符时。非常感谢任何帮助。
【问题讨论】:
标签: macros lisp common-lisp