我怎样才能在 LISP 中用 N 个参数定义一个宏?

How can I define a macro in LISP with N arguments?

我正在尝试在 LISP 中定义一个宏,例如在不同文件中的这个调用函数

(set_name name My name is Timmy)

(set_name occupation I am a doctor )

(defmacro set_name (list)
   (print list)
)

就像在普通函数中一样,使用&rest将所有剩余的参数收集到一个列表中。

(defmacro set_name (name &rest list) 
  `(setq ,name ',list))
(set_name occupation I am a doctor)
(print occupation)

这将打印 (I AM A DOCTOR)

您需要在扩展中引用 ,list,这样它就不会尝试将所有符号都作为变量求值。