在 Chibi 和 CHICKEN 中,以下 syntax-rules
表达式计算为一个过程:
(syntax-rules () ((_) #f))
这只是这些特定实现的编写方式的产物吗? Scheme 语言规范似乎没有指出 syntax-rules
能够计算出一个值。
更新
这似乎取决于Scheme的版本?
Semantics: An instance of syntax-rules evaluates, at macro-expansion time, to a new macro transformer by specifying a sequence of hygienic rewrite rules. A use of a macro whose keyword is associated with a transformer specified by syntax-rules is matched against the patterns contained in the s, beginning with the leftmost . When a match is found, the macro use is transcribed hygienically according to the template. It is a syntax violation when no match is found.
Semantics: An instance of syntax-rules produces a new macro transformer by specifying a sequence of hygienic rewrite rules. A use of a macro whose keyword is associated with a transformer specified by syntax-rules is matched against the patterns contained in the syntax rules, beginning with the leftmost syntax rule. When a match is found, the macro use is transcribed hygienically according to the template.
最佳答案
syntax-rules返回一个 transformer,它是 expander 用来将句法扩展转换为另一个句法扩展的过程。另见 here .
所以不,它不是一种特殊形式(同时它已经从你的问题中消失了),是的,它的计算结果是一个值,因为 Scheme 有 first-class procedures因此程序就是值(value)。
这是 Scheme 的标准行为,而不是 Chicken 或 Chibi 的实现细节。
关于scheme - 语法规则表达式本身是否在 Scheme 中计算为一个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24392437/