Why does the nested quasiquote not unwrap splice-unquote?

江枫思渺然 提交于 2019-12-11 06:03:46

问题


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)))))))

回答1:


In the first example

(quasiquote (quasiquote (unquote (quasiquote (unquote-splicing x)))))

This has 3 quasiquotes and 2 unquotes, so 'x' will not be evaluated.

in the second example

(quasiquote (quasiquote (unquote (quasiquote (unquote (unquote x))))))

there are 3 quasiquotes and 3 unquotes so 'x' will be replaced by it's value.



来源:https://stackoverflow.com/questions/56040935/why-does-the-nested-quasiquote-not-unwrap-splice-unquote

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!