Macros 公共Lisp宏变量展开

Macros 公共Lisp宏变量展开,macros,common-lisp,variable-expansion,Macros,Common Lisp,Variable Expansion,不会定义函数bart,因为,xt被读取为变量xt,而不是变量x加上一个t。但是有没有办法通过提供参数来获取函数bart?您需要创建函数名(然后是字符串),然后将其转换为符号,例如: (defmacro foo (x) `(defun ,xt () (format t "hullo"))) (foo bar) 然后 您需要创建函数名(然后是字符串),然后将其转换为符号,例如: (defmacro foo (x) `(defun ,xt ()

不会定义函数
bart
,因为
,xt
被读取为变量
xt
,而不是变量
x
加上一个
t
。但是有没有办法通过提供参数来获取函数
bart

您需要创建函数名(然后是字符串),然后将其转换为符号,例如:

(defmacro foo (x)
    `(defun ,xt ()
         (format t "hullo")))

(foo bar)
然后


您需要创建函数名(然后是字符串),然后将其转换为符号,例如:

(defmacro foo (x)
    `(defun ,xt ()
         (format t "hullo")))

(foo bar)
然后

? (foo bar)
BART
? (bart)
hullo
NIL