Lisp形式和Lisp表达式是同一回事吗? [英] Are Lisp forms and Lisp expressions same thing?

查看:100
本文介绍了Lisp形式和Lisp表达式是同一回事吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些文献说以下形式的第一个子形式..."或求值形式...",而另一些文献说求值表达式...",大多数文献似乎都使用这两种形式.条款.这两个术语可以互换吗?含义上有区别吗?

Some literature say "the first subform of the following form..." or "to evaluate a form..." while some other literature say "To evaluate an expression...", and most literature seem to use both terms. Are the two terms interchangeable? Is there a difference in meaning?

推荐答案

这些术语的定义和使用因Lisp方言和社区而异,因此对于Lisps,您的问题通常没有明确的答案.

The definitions and uses of these terms vary by Lisp dialect and community, so there is no clear answer to your question for Lisps in general.

有关它们在Common Lisp中的使用,请参见Rainers详细答案.给出简短摘要:

For their use in Common Lisp, see Rainers detailed answer. To give a short summary:

form 的HyperSpec条目:

表格n. 1.任何要评估的对象. 2.符号,化合物 形式或自我评估的对象. 3.(对于操作员,如 <<operator>> form'') a compound form having that operator as its first element.引号形式是常量形式.''

form n. 1. any object meant to be evaluated. 2. a symbol, a compound form, or a self-evaluating object. 3. (for an operator, as in <<operator>> form'') a compound form having that operator as its first element.A quote form is a constant form.''

表达式 的HyperSpec条目:

表达式1.物体,通常用来强调使用 以特殊格式编码或表示信息的对象, 例如程序文本. The second expression in a let form is a list of bindings.'' 2. the textual notation used to notate an object in a source file.表达式'sample等效于(quote 样本).

expression n. 1. an object, often used to emphasize the use of the object to encode or represent information in a specialized format, such as program text. The second expression in a let form is a list of bindings.'' 2. the textual notation used to notate an object in a source file.The expression 'sample is equivalent to (quote sample).''

因此,根据HyperSpec,表达式用于(文本)表示,而 form 用于Lisp 要评估的对象.但是,如上所述,这只是在HyperSpec(以及Common Lisp)的上下文中对这些术语的定义.

So, according to the HyperSpec, expression is used for the (textual) representation, while form is used for Lisp objects to be evaluated. But, as I said above, this is only the definition of those terms in the context of the HyperSpec (and thus Common Lisp).

但是,在Scheme中,R5RS完全没有提到 form ,仅谈论 expressions . R6RS甚至给出了几乎与上面完全相反的定义:

In Scheme, however, the R5RS doesn't mention form at all, and talks about expressions only. The R6RS even gives a definition that almost sounds like the exact opposite of the above:

在纯语法层面上,两者都是形式,而形式是 Scheme程序的语法部分的通用名称.

At the purely syntactical level, both are forms, and form is the general name for a syntactic part of a Scheme program.

(谈论(define …)(* …)之间的区别.)

(Talking about the difference between (define …) and (* …).)

这篇关于Lisp形式和Lisp表达式是同一回事吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆