我對傳遞給宏的參數如何得到評估有疑問,細節如下。在宏體內傳遞參數的評估
這個宏定義
(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
在第一種情況下沒有得到評估,即應用了*
操作符。任何幫助,高度讚賞。
非常感謝。宏觀膨脹是超級有用的.. – 5Fists 2013-02-27 15:39:54
@ 5fists有一個熱鍵macroexpand在粘液;這是1,slimv – 2013-02-28 06:56:31