Difference between revisions of "Closure (computer programming)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(First)
 
(ital)
Line 17: Line 17:
 
* [https://en.wikipedia.org/wiki/Closure_(computer_programming) Closure (computer programming)]
 
* [https://en.wikipedia.org/wiki/Closure_(computer_programming) Closure (computer programming)]
  
The term closure has many different uses in different fields.  See:
+
The term ''closure'' has many different uses in different fields.  See:
  
 
* [https://en.wikipedia.org/wiki/Closure Closure] @ Wikipedia
 
* [https://en.wikipedia.org/wiki/Closure Closure] @ Wikipedia

Revision as of 07:29, 15 June 2015

In programming languages, closures (also lexical closures or function closures) are a technique for implementing lexically scoped name binding in languages with first-class functions.

Operationally, a closure is a data structure storing a function[a] together with an environment:

  • A mapping associating each free variable of the function (variables that are used locally, but defined in an enclosing scope)
  • With the value or storage location the name was bound to at the time the closure was created.

A closure -- unlike a plain function -- allows the function to access those captured variables through the closure's reference to them, even when the function is invoked outside their scope.

See also

External links

The term closure has many different uses in different fields. See: