本文介绍了为什么嵌套的准引用不能解开拼接-取消引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么第一个宏unquote-splicing
不产生(quasiquote (unquote (quasiquote 1 2)))
,但是第二个示例替换了该值?
Why does the first macro unquote-splicing
not produce (quasiquote (unquote (quasiquote 1 2)))
, but the second example replaces the value?
(define x (list 1 2))
(t '(quasiquote (unquote (quasiquote (unquote-splicing x))))
(quasiquote (quasiquote (unquote (quasiquote (unquote-splicing x))))))
(t '(quasiquote (unquote (quasiquote (unquote (1 2)))))
(quasiquote (quasiquote (unquote (quasiquote (unquote (unquote x)))))))
推荐答案
在第一个示例中
(quasiquote (quasiquote (unquote (quasiquote (unquote-splicing x)))))
这有3个准引号和2个非引号,因此不会评估'x'.
This has 3 quasiquotes and 2 unquotes, so 'x' will not be evaluated.
在第二个示例中
(quasiquote (quasiquote (unquote (quasiquote (unquote (unquote x))))))
有3个准引号和3个非引号,因此'x'将被其值替换.
there are 3 quasiquotes and 3 unquotes so 'x' will be replaced by it's value.
这篇关于为什么嵌套的准引用不能解开拼接-取消引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!