微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

clojure – Lisp表单和Lisp表达式是否相同?

一些文学说“以下形式的第一个子形式”或“评估一个形式…”,而其他一些文献则说“评价表达式”,大多数文献似乎都使用这两个术语。这两个术语是否可以互换?意思有差异吗?

解决方法

这些术语的定义和用法因Lisp方言和社区而异,所以对于您对Lisps的一般问题,您没有明确的答案。

为了在Common Lisp中使用它们,请参阅Rainers的详细答案。简要总结一下:

form的HyperSpec条目:

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.”

expression的HyperSpec条目:

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,表达式用于(文本)表示,而表单用于要评估的Lisp对象。但是,如上所述,这只是在HyperSpec(因此Common Lisp)的上下文中这些术语的定义。

然而,在计划中,R5RS根本就没有提及形式,仅谈论表达。 r6rs甚至给出了一个几乎听起来像上面正好相反的定义:

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

(谈论(定义…)和(* …)之间的区别。)

原文地址:https://www.jb51.cc/html/232755.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐