clojure 语法引用和取消引用
示例
来自标准库(core.clj:807)的示例:
(defmacro and
"Evaluates exprs one at a time, from left to right. If a form
returns logical false (nil or false), and returns that value and
doesn't evaluate any of the other expressions, otherwise it returns
the value of the last expr. (and) returns true."
{:added "1.0"}
([] true)
([x] x)
([x & next]
`(let [and# ~x]
(if and# (and ~@next) and#))))`所谓语法的报价是一样(quote)的,但递归的:它会导致(let…),(if…)等宏扩展过程中,但作为被输出到未评估
~akaunquote取消语法引用形式内单个形式的语法引用。因此,x在扩展宏时会输出的值(而不是输出x符号)
~@akaunquote-splicing就像unquote一样,但是使用list参数并将其扩展,每个列表项以单独的形式
#将唯一的ID附加到符号上,以防止名称冲突。它在语法引用的表达式内为同一符号附加相同的id,因此and#insidelet和and#insideif将获得相同的名称
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短