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

橙三吉。 提交于 2019-12-05 06:51:29

You're right; this text is not referring to "closures"--an implementation strategy to ensure that functions-as-values refer correctly to lexical bindings--but more generally to the mathematical notion of "closure", as for instance in the statement "the integers are closed under the addition operation". That is: applying the operation to any two elements of the set produces a result that is still a member of the set.

There is a difference in the use of "closure" in SICP from the way it is typically used in computing. From SICP Chapter 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.

On the other hand, Schemer's use "closure" to refer to lexical closures just like programmers using other languages with lexical closures.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!