scheme - 语法规则表达式本身是否在 Scheme 中计算为一个值?

标签 scheme chicken-scheme language-specifications chibi-scheme

在 Chibi 和 CHICKEN 中,以下 syntax-rules 表达式计算为一个过程:

(syntax-rules () ((_) #f))

这只是这些特定实现的编写方式的产物吗? Scheme 语言规范似乎没有指出 syntax-rules 能够计算出一个值。


更新

这似乎取决于Scheme的版本?

From the R6RS Spec :

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.

来自R5RS SpecR7RS Spec :

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/

相关文章:

python - Python 的任何/全部的短路行为是显式的吗?

scheme - 可执行文件大小可以优化吗?

scheme - Chicken计划中的图书馆单元是什么?

scheme - 是否有加载 SRFI 的标准化方法?

functional-programming - 如何在 Dr.Racket 中重新分配值

f# - 为什么函数内部允许 "do"?

c++ - 根据 C/C++ 标准, "'“与 "\' 相同”吗?

algorithm - Tic Tac Toe MiniMax 方案

sum - Scheme编程求和函数重载

sorting - 在交换过程中无法获得我想要的最终列表