我的理解是:闭包即是使用了非局部变量的函数,该函数没有被释放,该非局部变量也不会被释放,强调了它们之间的绑定关系。
2 回复
In programming languages, closures (also lexical closures or function closures) are techniques for implementing lexically scoped name binding in languages with first-class functions. Operationally, a closure is a record storing a function[a] together with an environment:[1] a mapping associating each free variable of the function (variables that are used locally, but defined in an enclosing scope) with the value or reference to which the name was bound when the closure was created.[b] A closure—unlike a plain function—allows the function to access those captured variables through the closure's copies of their values or references, even when the function is invoked outside their scope.
你说的内容是编程语言/计算机里闭包的存在方式,是一种表现,
核心的还是因为计算封闭于scope。
你尚未登录,无法进行回复。