问题描述
我对这些术语困惑了很长时间,认为最好弄清楚它们的确切含义:
I am confused by the terms for a long time, thinking it is good to ask out what exactly do they mean:
A.句法.B. 语法值.C. 语法对象.D.s-expression E.datum (in syntax->datum)
A. syntax. B. syntax value. C. syntax object. D.s-expression E.datum (in syntax->datum)
- s 表达式和符号有什么区别?
- s 表达式和数据之间有什么区别?
- (语法、语法值和语法对象)与 s-expression 有什么区别?
- 用于解释的代码示例将不胜感激.
推荐答案
"Syntax" 是 Racket 中表示源代码的一种类型,它是 S-expression 的包装器(参见 最近的博文 了解详情).Syntax value"和syntax object"都是this的同义词,古代mzscheme
语言函数处理语法使用syntax-value
的名字.现在我们更多地只使用语法",而对于复数形式,我们使用语法".
"Syntax" is a type for representing source code in Racket, which is a wrapper around S-expression (see a recent blog post for details). "Syntax value" and "syntax object" are all synonyms of this, and ni the ancient days of the mzscheme
language functions that deal with syntax used syntax-value
in the name. These days we use just "syntax" more often, and for a plural form we use "syntaxes".
S 表达式"是可以用代码输入的原始数据(符号、数字、字符串、布尔值等——在 Racket 中,您还可以包括其他类型),或者是这些内容的列表.因此,S 表达式是在边缘由这些基本类型构成的列表的任何嵌套结构.有时这也包括向量(因为它们可以使用 #(...)
语法输入)但更常见的是它们被排除在外.
An "S-expression" is either a primitive piece of data that can be typed in code (symbols, numbers, strings, booleans, etc -- in Racket you could also include other types), or a list of these things. An S-expression is therefore any nested structure of lists made of these primitive types at the fringe. Sometimes this includes vectors too (since they can be typed in using the #(...)
syntax) but more usually they're left out.
最后,数据"是 S 表达式的另一个名称,有时当您想指代它是具有输入表示的一段数据这一事实时.你可以看到 R5RS 是如何介绍它的: 可以是 Scheme 对象 [...] 的任何外部表示.此表示法用于在 Scheme 代码中包含文字常量.
Finally, "datum" is another name for an S-expression, sometimes when you want to refer to the fact that it's a piece of data that has an input representation. You can see how R5RS introduces it: <Datum>
may be any external representation of a Scheme object [...]. This notation is used to include literal constants in Scheme code.
至于您的问题:
s 表达式和符号有什么区别?
What's the difference between s-expression and symbol?
符号是 S 表达式,S 表达式可能包含符号.
A symbols is an S-expression, an S-expression may contain symbols.
s-expression 和 datum 有什么区别?
What's the difference between s-expression and datum?
真的没什么.(尽管可能存在一些细微的意图差异.)
Nothing really. (Although some subtle intentions differences might be there.)
(语法、语法值和语法对象)与 s-expression 有什么区别?
What's the difference between (syntax, syntax values and syntax object) from s-expression?
它们是球拍中宏使用的程序语法的表示——它们包含 S-表达式,但它们添加了源位置信息、词法上下文、语法属性和证书.请参阅该博文以获取简要介绍.
They are the representation of program syntax used by macros in racket -- they contain the S-expressions, but they add source location information, lexical context, syntax properties, and certificates. See that blog post for a quick introduction.
这篇关于Racket 中的一些宏观术语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!