Scheme 中的闭包和其他语言中通常的闭包有什么区别吗?

Is there any difference between closure in Scheme and usual closure in other languages?

我现在正在学习SICP。我发现 SICP 中 closure 的定义(可能)与其他语言中的闭包定义不同。

SICP 是这样说的:

The ability to create pairs whose elements are pairs is the essence of list structure's importance as a representational tool. We refer to this ability as the closure property of cons. In general, an operation for combining data objects satisfies the closure property if the results of combining things with that operation can themselves be combined using the same operation.

这里的闭包我觉得更接近于数学中的闭包,而不是我在JavaScript看到的,意思是函数访问封闭环境变量的能力

我错了吗?

你是对的;这篇文章不是指 "closures"——一种确保函数作为值正确引用词法绑定的实现策略——而是更一般地指 "closure" 的数学概念,例如在声明 "the integers are closed under the addition operation"。即:将操作应用于集合中的任意两个元素产生的结果仍然是集合的成员。

"closure" 在 SICP 中的使用与它通常用于计算的方式不同。来自 SICP 第 2 章,footnote 6:

The use of the word 'closure' here comes from abstract algebra, where a set of elements is said to be closed under an operation if applying the operation to elements in the set produces an element that is again an element of the set. The Lisp community also (unfortunately) uses the word 'closure' to describe a totally unrelated concept: A closure is an implementation technique for representing procedures with free variables. We do not use the word 'closure' in this second sense in this book.

另一方面,Schemer 使用 "closure" 来引用 lexical closures 就像程序员使用其他带有词法闭包的语言一样。