Closure (computer Science)

Closure (computer Science)

In computer science, a closure (also lexical closure or function closure) is a function or reference to a function together with a referencing environment—a table storing a reference to each of the non-local variables (also called free variables) of that function. A closure—unlike a plain function pointer—allows a function to access those non-local variables even when invoked outside of its immediate lexical scope.

The concept of closures was developed in the 1960s and was first fully implemented in 1975 as a language feature in the Scheme programming language to support lexically scoped first-class functions. The explicit use of closures is associated with functional programming languages such as Lisp and ML, as traditional imperative languages such as Algol, C and Pascal did not support returning nested functions as results of higher-order functions and thus did not require supporting closures either. Many modern garbage-collected imperative languages (such as Smalltalk, the first object-oriented language featuring closures, C#, but notably not Java) support closures.

Read more about Closure (computer Science):  Example, History and Etymology, Implementation and Theory, Applications, Closure-like Constructs

Other articles related to "closures":

Closure (computer Science) - Closure-like Constructs - Inline Agents (Eiffel)
... Eiffel includes inline agents defining closures ... An inline agent is an object representing a routine,defined by giving the code of the routine in-line ... For example,in ok_button.click_event.subscribe agent x,y INTEGER)do map.country_at_coordinates x,y)display end the argument to subscribe is an agent,representing a procedure with two arguments the procedure ...