为什么在此宏定义中需要@符号? [英] Why is the @ sign needed in this macro definition?
本文介绍了为什么在此宏定义中需要@符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的时候是宏:
(defmacro when (condition &rest body)
`(if ,condition (progn ,@body)))
为什么有一个at符号?
Why is the there an at sign?
推荐答案
通过进行一些实验很容易看到差异
It's very easy to see the difference by making a little experiment
> (let ((x '(1 2 3 4))) `(this is an example ,x of expansion))
(THIS IS AN EXAMPLE (1 2 3 4) OF EXPANSION)
> (let ((x '(1 2 3 4))) `(this is an example ,@x of expansion))
(THIS IS AN EXAMPLE 1 2 3 4 OF EXPANSION)
如您所见,使用,@
会将列表的元素直接放置在扩展中.取而代之的是将列表放置在扩展中.
As you can see the use of ,@
will place the elements of the list directly inside in the expansion. Without you get instead the list placed in the expansion.
这篇关于为什么在此宏定义中需要@符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文