Knowledge (XXG)

Closure (computer programming)

Source đź“ť

5115:
explicitly allocating the variable 'a' on heap, or using structs or class to store all needed closed variables and construct a delegate from a method implementing the same code. Closures can be passed to other functions, as long as they are only used while the referenced values are still valid (for example calling another function with a closure as a callback parameter), and are useful for writing generic data processing code, so this limitation, in practice, is often not an issue.
1547:-like lexical scope system with dynamic variables and garbage collection, lacks a stack programming model and does not suffer from the limitations of stack-based languages. Closures are expressed naturally in Scheme. The lambda form encloses the code, and the free variables of its environment persist within the program as long as they can possibly be accessed, and so they can be used as freely as any other Scheme expression. 1533:), it is very easy to implement automatic memory management (garbage collection), as there are no possible cycles in variables' references. For example, in Erlang, all arguments and variables are allocated on the heap, but references to them are additionally stored on the stack. After a function returns, references are still valid. Heap cleaning is done by incremental garbage collector. 5766:
of "open" Lambda expressions (functions in LISP are usually Lambda expressions) and "closed" Lambda expressions. My interest in the environment problem began while Landin, who had a deep understanding of the problem, visited MIT during 1966–67. I then realized the correspondence between the FUNARG lists which are the results of the evaluation of "closed" Lambda expressions in
2167:, bind variables directly to values. In this case, since there is no way to change the value of the variable once it is bound, there is no need to share the state between closures—they just use the same values. This is often called capturing the variable "by value". Java's local and anonymous classes also fall into this category—they require captured local variables to be 1486:. In such languages, a function's automatic local variables are deallocated when the function returns. However, a closure requires that the free variables it references survive the enclosing function's execution. Therefore, those variables must be allocated so that they persist until no longer needed, typically via 5765:
A useful metaphor for the difference between FUNCTION and QUOTE in LISP is to think of QUOTE as a porous or an open covering of the function since free variables escape to the current environment. FUNCTION acts as a closed or nonporous covering (hence the term "closure" used by Landin). Thus we talk
2038:
For this example the expected behaviour would be that each link should emit its id when clicked; but because the variable 'e' is bound to the scope above, and lazy evaluated on click, what actually happens is that each on click event emits the id of the last element in 'elements' bound at the end of
1190:
returns, even though execution has left their scope and they are no longer visible. In languages without closures, the lifetime of an automatic local variable coincides with the execution of the stack frame where that variable is declared. In languages with closures, variables must continue to exist
528:
Lastly, a closure is only distinct from a function with free variables when outside of the scope of the non-local variables, otherwise the defining environment and the execution environment coincide and there is nothing to distinguish these (static and dynamic binding cannot be distinguished because
524:
The nested function definitions are not themselves closures: they have a free variable which is not yet bound. Only once the enclosing function is evaluated with a value for the parameter is the free variable of the nested function bound, creating a closure, which is then returned from the enclosing
1474:
the non-local names to the corresponding variables in the lexical environment at the time the closure is created, additionally extending their lifetime to at least as long as the lifetime of the closure. When the closure is entered at a later time, possibly with a different lexical environment, the
5447:
The main limitation of Eiffel agents, which distinguishes them from closures in other languages, is that they cannot reference local variables from the enclosing scope. This design decision helps in avoiding ambiguity when talking about a local variable value in a closure - should it be the latest
1603:
binding also differs. In imperative languages, variables bind to relative locations in memory that can store values. Although the relative location of a binding does not change at runtime, the value in the bound location can. In such languages, since closure captures the binding, any operation on
5949:
If you try to call the nested function through its address after the containing function exits, all hell breaks loose. If you try to call it after a containing scope level exits, and if it refers to some of the variables that are no longer in scope, you may be lucky, but it's not wise to take the
4016:
of an enclosing class. They are normally referred to just as "inner classes". These are defined in the body of the enclosing class and have full access to instance variables of the enclosing class. Due to their binding to these instance variables, an inner class may only be instantiated with an
3205:
pointer to arbitrary data of the user's choice. When the library executes the callback function, it passes along the data pointer. This enables the callback to maintain state and to refer to information captured at the time it was registered with the library. The idiom is similar to closures in
5118:
This limitation was fixed in D version 2 - the variable 'a' will be automatically allocated on the heap because it is used in the inner function, and a delegate of that function can escape the current scope (via assignment to dg or return). Any other local variables (or arguments) that are not
4318:
Upon execution, this will print the integers from 0 to 9. Beware to not confuse this type of class with the nested class, which is declared in the same way with an accompanied usage of the "static" modifier; those have not the desired effect but are instead just classes with no special binding
2417:
invokes the escape continuation established for the method invocation, ignoring the escape continuations of any intervening nested closures. The escape continuation of a particular closure can only be invoked in Smalltalk implicitly by reaching the end of the closure's code. These examples in
5114:
D version 1, has limited closure support. For example, the above code will not work correctly, because the variable a is on the stack, and after returning from test(), it is no longer valid to use it (most probably calling foo via dg(), will return a 'random' integer). This can be solved by
1536:
In ML, local variables are lexically scoped, and hence define a stack-like model, but since they are bound to values and not to objects, an implementation is free to copy these values into the closure's data structure in a way that is invisible to the programmer.
5119:
referenced by delegates or that are only referenced by delegates that do not escape the current scope, remain on the stack, which is simpler and faster than heap allocation. The same is true for inner's class methods that reference a function's variables.
1522:
for variables. D version 2 solved this by detecting which variables must be stored on the heap, and performs automatic allocation. Because D uses garbage collection, in both versions, there is no need to track usage of variables as they are passed.
1517:
and automatic local variables, as their references will be invalid after return from its definition scope (automatic local variables are on the stack) – this still permits many useful functional patterns, but for complex cases needs explicit
5146:. A C++ closure may capture its context either by storing copies of the accessed variables as members of the closure object or by reference. In the latter case, if the closure object escapes the scope of a referenced object, invoking its 1594:
As different languages do not always have a common definition of the lexical environment, their definitions of closure may vary also. The commonly held minimalist definition of the lexical environment defines it as a set of all
867:—in other words, such languages enable functions to be passed as arguments, returned from function calls, bound to variable names, etc., just like simpler types such as strings and integers. For example, consider the following 2369:—which in this case results in division by zero. However, since it is the computation that is captured, and not the value, the error only manifests when the closure is invoked, and then attempts to use the captured binding. 1497:. The alternatives are manual memory management of non-local variables (explicitly allocating on the heap and freeing when done), or, if using stack allocation, for the language to accept that certain use cases will lead to 5435:
for a certain button, so that whenever an instance of the event type occurs on that button – because a user has clicked the button – the procedure will be executed with the mouse coordinates being passed as arguments for
520:
A closure is a value like any other value. It does not need to be assigned to a variable and can instead be used directly, as shown in the last two lines of the example. This usage may be deemed an "anonymous closure".
5633:
Sussman and Steele. "Scheme: An interpreter for extended lambda calculus". "... a data structure containing a lambda expression, and an environment to be used when that lambda expression is applied to arguments."
5138:. These objects behave somewhat like functions in a functional programming language. They may be created at runtime and may contain state, but they do not implicitly capture local variables as closures do. As of 1604:
the variable, whether done from the closure or not, are performed on the same relative memory location. This is often called capturing the variable "by reference". Here is an example illustrating the concept in
3874:
reference to a mutable container, for example, a one-element array. The local class will not be able to change the value of the container reference, but it will be able to change the contents of the container.
3229:
by associating general functions of graphical widgets (menus, buttons, check boxes, sliders, spinners, etc.) with application-specific functions implementing the specific desired behavior for the application.
1262:'s standard control structures, including branches (if/then/else) and loops (while and for), are defined using objects whose methods accept closures. Users can easily define their own control structures also. 844:
can thus be implemented with closures. In some languages, a closure may occur when a function is defined within another function, and the inner function refers to local variables of the outer function. At
5456:
in Java), its features, and arguments of the agent can be accessed from within the agent body. The values of the outer local variables can be passed by providing additional closed operands to the agent.
1265:
In languages which implement assignment, multiple functions can be produced that close over the same environment, enabling them to communicate privately by altering that environment. In Scheme:
6260: 849:, when the outer function executes, a closure is formed, consisting of the inner function's code and references (the upvalues) to any variables of the outer function required by the closure. 5802:
The reason it is called a "closure" is that an expression containing free variables is called an "open" expression, and by associating to it the bindings of its free variables, you close it.
5431:
is an agent, representing a procedure with two arguments; the procedure finds the country at the corresponding coordinates and displays it. The whole agent is "subscribed" to the event type
5635: 3242:(GCC) extension, a nested function can be used and a function pointer can emulate closures, provided the function does not exit the containing scope. The next example is invalid because 641:
This is most often achieved by a function return, since the function must be defined within the scope of the non-local variables, in which case typically its own scope will be smaller.
1509:(or "functional argument" problem) describes the difficulty of implementing functions as first class objects in a stack-based programming language such as C or C++. Similarly in 1470:, plus a representation of the function's lexical environment (i.e., the set of available variables) at the time when the closure was created. The referencing environment 4906:, closures are implemented by delegates, a function pointer paired with a context pointer (e.g. a class instance, or a stack frame on the heap in the case of closures). 976:
function, which calls it repeatedly to determine which books are to be added to the result list and which are to be discarded. Because the closure has a reference to
1859:
In some instances the above behaviour may be undesirable, and it is necessary to bind a different lexical closure. Again in ECMAScript, this would be done using the
4500:. Normal local variables are captured by value when the block is created, and are read-only inside the block. Variables to be captured by reference are marked with 5342:
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
648:(which reduces the scope of the non-local variable), though this is less common in practice, as it is less useful and shadowing is discouraged. In this example 2174:
Some languages enable choosing between capturing the value of a variable or its location. For example, in C++11, captured variables are either declared with
1258:
Because closures delay evaluation—i.e., they do not "do" anything until they are called—they can be used to define control structures. For example, all of
2891:
control statement is explicit (and only arbitrarily named 'return' for the sake of the example). The following is a direct translation of the Ruby sample.
785:, or passed as arguments to other function calls; if functions with free variables are first-class, then returning one creates a closure. This includes 5614:
These names usually refer to values, mutable variables, or functions, but can also be other entities such as constants, types, classes, or labels.
5142:, the C++ language also supports closures, which are a type of function object constructed automatically from a special language construct called 2654:. Hence, Smalltalk makes it possible for a captured escape continuation to outlive the extent in which it can be successfully invoked. Consider: 2401:, such interpretation requires looping constructs to be considered in terms of recursive function calls). In some languages, such as ECMAScript, 6255: 6116: 6001: 1562:
languages is whether the variables in a closure can be updated and, if so, how these updates can be synchronized. Actors provide one solution.
6058: 5675: 1494: 1192: 961:. When the lambda expression is evaluated, Scheme creates a closure consisting of the code for the lambda expression and a reference to the 3674: 3691:
classes). A local class (either named or anonymous) may refer to names in lexically enclosing classes, or read-only variables (marked as
3201:. This is sometimes implemented by providing two values when registering the callback with the library: a function pointer and a separate 1490:, rather than on the stack, and their lifetime must be managed so they survive until all closures referencing them are no longer in use. 3670: 846: 3246:
is a top-level definition (depending on compiler version, it could produce a correct result if compiled with no optimizing, i.e., at
6233: 5858: 5795: 1211:
of the variable encompasses only the closed-over function, so it cannot be accessed from other program code. These are analogous to
509:
are functionally identical. The only difference in implementation is that in the first case we used a nested function with a name,
5662:. Lecture Notes in Computer Science. Vol. 7829. Springer. pp. 1–20 See 12 §2, note 8 for the claim about M-expressions. 5976: 99:
to which the name was bound when the closure was created. Unlike a plain function, a closure allows the function to access those
1070: 3198: 810: 1475:
function is executed with its non-local variables referring to the ones captured by the closure, not the current environment.
5874: 4696: 3166: 2717:
that created the closure. Since that call has already returned and the Smalltalk method invocation model does not follow the
219: 2876:
in this example are ways to create a closure, but semantics of the closures thus created are different with respect to the
5339: 4470: 4461: 2884: 1540: 1530: 1483: 1243: 868: 802: 238: 170: 3760:// The expression "new Runnable() { ... }" is an anonymous class implementing the 'Runnable' interface. 5598: 1204: 798: 96: 5900: 196:, rather than the prior use in computer science. The authors consider this overlap in terminology to be "unfortunate." 6179: 3666: 3174: 2725: 1443: 1216: 806: 790: 227: 174: 84: 5731:(June 1970). "The Function of FUNCTION in LISP, or Why the FUNARG Problem Should Be Called the Environment Problem". 1234:, so a value established in one invocation remains available in the next. Closures used in this way no longer have 829: 157:
with open bindings (free variables) that have been closed by (or bound in) the lexical environment, resulting in a
116: 103:
through the closure's copies of their values or references, even when the function is invoked outside their scope.
5950:
risk. If, however, the nested function does not refer to anything that has gone out of scope, you should be safe.
2164: 2071:// Incorrect: e is bound to the function containing the 'for' loop, not the closure of "handle" 837: 794: 80: 2405:
refers to the continuation established by the closure lexically innermost with respect to the statement—thus, a
4903: 4474: 3226: 3218: 3194: 3170: 1514: 1510: 1235: 1191:
as long as any existing closures have references to them. This is most commonly implemented using some form of
223: 92: 35: 5848: 6040: 5577: 3239: 497:
with a free variable from the enclosing function, so that the free variable binds to the value of parameter
6190:
discussing, among other things, the versatility of closures in the context of Scheme (where they appear as
6139: 4802:, which has many language features similar to those of C#, also supports lambda expressions with closures: 5695: 1600: 1559: 1231: 786: 6080: 4326:, Java supports functions as first class objects. Lambda expressions of this form are considered of type 2191:, bind variables to results of future computations rather than values. Consider this example in Haskell: 1478:
A language implementation cannot easily support full closures if its run-time memory model allocates all
529:
the names resolve to the same values). For example, in the program below, functions with a free variable
4486: 782: 193: 76: 31: 2377:
Yet more differences manifest themselves in the behavior of other lexically scoped constructs, such as
1599:
in the scope, and that is also what closures in any language have to capture. However the meaning of a
1178:
Because the closure in this case outlives the execution of the function that creates it, the variables
111:
The concept of closures was developed in the 1960s for the mechanical evaluation of expressions in the
4012:
that are declared within the body of a method. Java also supports inner classes that are declared as
3360:// & operator is optional here because the name of a function in C is a pointer pointing on itself 6265: 4323: 3878:
With the advent of Java 8's lambda expressions, the closure causes the above code to be executed as:
1226:
In stateful languages, closures can thus be used to implement paradigms for state representation and
951: 858: 517:
for creating an anonymous function). The original name, if any, used in defining them is irrelevant.
120: 72: 49: 5926: 6098: 6066: 5567: 3182: 2390: 1570: 1498: 1451: 1208: 6202: 1505:
to freed automatic variables, as in lambda expressions in C++11 or nested functions in GNU C. The
6187: 5840: 5814: 5752: 5154: 1578: 1479: 1227: 864: 833: 778: 645: 215: 205: 162: 154: 188:
in the 1980s with a second, unrelated meaning: the property of an operator that adds data to a
6183: 5854: 5818: 5791: 5671: 5572: 4799: 4504:. Blocks that need to persist outside of the scope they are created in may need to be copied. 841: 166: 91:
of the function (variables that are used locally, but defined in an enclosing scope) with the
6239: 5744: 5736: 5710: 5663: 5652: 5602: 1554:
of concurrent computation where the values in the function's lexical environment are called
1502: 1467: 1220: 1212: 822: 65: 6026: 5940: 5323:// 'i' is now either 'n.end()' or points to the first string in 'n' 3161:
Some languages have features which simulate the behavior of closures. In languages such as
6192: 6165: 5648: 5562: 5552: 5131: 4482: 3683: 2718: 2184: 1566: 1519: 1487: 513:, while in the second case we used an anonymous nested function (using the Python keyword 494: 17: 5150:
causes undefined behavior since C++ closures do not extend the lifetime of their context.
6242:: An example of a technical domain where using closures is convenient, by Martin Fowler. 6229: 5836: 3859:
variables enables capturing variables by value. Even if the variable to capture is non-
3222: 1574: 1506: 1463: 189: 181: 5326:// which is not equal to 'myname' and whose length is greater than 'y' 6249: 6214: 5844: 5479: 1239: 966: 814: 112: 88: 5756: 4330:
with T being the domain and U the image type. The expression can be called with its
3185:(VB.NET), these features are the result of the language's object-oriented paradigm. 6210: 5821:(December 1975). Scheme: An Interpreter for the Extended Lambda Calculus (Report). 5691: 2389:
statements. Such constructs can, in general, be considered in terms of invoking an
1596: 1471: 142: 126: 68: 5667: 4009: 3211: 3178: 2629: 1551: 1493:
This explains why, typically, languages that natively support closures also use
4493:.0. Apple made their implementation available for the GCC and clang compilers. 4017:
explicit binding to an instance of the enclosing class using a special syntax.
2721:
discipline to facilitate multiple returns, this operation results in an error.
1081:
function, but otherwise the structure and the effect of the code are the same.
192:
to also be able to add nested data structures. This use of the term comes from
5728: 5469:
to provide a pointer to a method with a similar syntax to a function pointer.
4466: 2648: 1605: 1454:
environment a closure, but the term usually refers specifically to functions.
1242:; nevertheless, they are commonly used in impure functional languages such as 992: 818: 146: 6225: 5714: 1230:, since the closure's upvalues (its closed-over variables) are of indefinite 5962: 5904: 5740: 5448:
value of the variable or the value captured when the agent is created? Only
2637: 2410: 1259: 1000:// Return a list of all books with at least 'threshold' copies sold. 87:
together with an environment. The environment is a mapping associating each
2409:
within a closure transfers control to the code that called it. However, in
6218: 5767: 5557: 1207:" variables, which persist over several invocations of the function. The 5139: 2632:
provides a construct that can express either of the above actions: Lisp
5822: 5760: 5748: 5474: 2188: 42: 3214:
so this C idiom differs from type-safe closures in C#, Haskell or ML.
2602:
The above code snippets will behave differently because the Smalltalk
1852:
all use the same relative memory location signified by local variable
777:
The use of closures is associated with languages where functions are
541:
is defined, so it is immaterial whether these are actually closures:
115:
and was first fully implemented in 1970 as a language feature in the
6103:
The Java Tutorials: Learning the Java Language: Classes and Objects
6085:
The Java Tutorials: Learning the Java Language: Classes and Objects
5127: 4478: 3162: 1977:// emits undefined as 'x' is not specified in global scope. 1513:
version 1, it is assumed that the programmer knows what to do with
1084:
A function may create a closure and return it, as in this example:
226:, whose non-local variables have been bound either to values or to 5771: 4490: 1544: 2713:
is invoked, it attempts to return a value from the invocation of
876:; Return a list of all books with at least THRESHOLD copies sold. 6143: 1092:// using an interval of dx, which should be appropriately small. 222:
without a name, while a closure is an instance of a function, a
5966:
Will Clinger. MIT Mathematics Doctoral Dissertation. June 1981.
4184:/* Instantiate the inner class, with binding to the instance */ 3870:
Capturing of variables by reference can be emulated by using a
1569:; the transformation from the former to the latter is known as 537:
with global scope) are executed in the same environment where
2614:
will leave the inner closure to begin a new iteration of the
1203:
A closure can be used to associate a function with a set of "
27:
Technique for creating lexically scoped first class functions
5517:
can be declared for a pointer to a method using this syntax:
5660:
International Symposium on Trends in Functional Programming
4699:
anonymous methods and lambda expressions support closure:
2393:
established by an enclosing control statement (in case of
1089:// Return a function that approximates the derivative of f 5901:"Re: FP, OO and relations. Does anyone trump the others?" 1450:
Note: Some speakers call any data structure that binds a
420:# Using closures without binding them to variables first. 5106:// =25 // ok, test2.a is in a closure and still exists 5085:// =10 // ok, test1.a is in a closure and still exists 2610:
operator are not analogous. In the ECMAScript example,
6166:
http://docwiki.embarcadero.com/RADStudio/Rio/en/Closure
3811:// It can access private fields of the enclosing class: 2152:
would need to be bound by the scope of the block using
218:, though strictly, an anonymous function is a function 3681:. When such classes are not named, they are known as 2163:
On the other hand, many functional languages, such as
995:, another popular language with support for closures: 4496:
Pointers to block and block literals are marked with
4473:, a form of closure, as a nonstandard extension into 3124:; prints "return from foo from inside proc" 2854:# prints "return from foo from inside proc" 1436:; prints "meet me by the docks at midnight" 797:, and many modern, multi-paradigm languages, such as 781:, in which functions can be returned as results from 2171:, which also means there is no need to share state. 1526:
In strict functional languages with immutable data (
493:
are closures, in both cases produced by returning a
6219:"Closures for the Java Programming Language (v0.5)" 2418:ECMAScript and Smalltalk highlight the difference: 2034:
Example 2: Accidental reference to a bound variable
955:(lambda (book) (>= (book-sales book) threshold)) 161:, or closure. This use was subsequently adopted by 6261:Implementation of functional programming languages 5653:"Some History of Functional Programming Languages" 5465:Embarcadero C++Builder provides the reserved word 1462:Closures are typically implemented with a special 1223:(or functors) with a single call-operator method. 5850:Structure and Interpretation of Computer Programs 3943:// The code () -> { /* code */ } is a closure. 41:Not to be confused with the programming language 2361:captured by the closure defined within function 1974:// The function gets invoked at the global scope 2622:will abort the loop and return from the method 1219:, and in fact closures are similar to stateful 6059:"Nested, Inner, Member, and Top-Level Classes" 1550:Closures are closely related to Actors in the 821:, where they are used for interactions with a 5452:(a reference to current object, analogous to 4334:method, but not with a standard method call. 2177:, which means captured by reference, or with 8: 6140:"Programming with C Blocks on Apple Devices" 2971:"return from foo from inside proc" 2770:"return from foo from inside proc" 1415:"meet me by the docks at midnight" 863:Closures typically appear in languages with 5155:Anonymous function § C++ (since C++11) 1867:Example 1: Reference to an unbound variable 501:of the enclosing function. The closures in 336:# Assigning specific closures to variables. 5930:C++ Standards Committee. 29 February 2008. 5696:"The mechanical evaluation of expressions" 2728:, enable the programmer to choose the way 1844:and the closures referred to by variables 3863:, it can always be copied to a temporary 3662:Local classes and lambda functions (Java) 375:# Using the closures stored in variables. 149:credits Landin with introducing the term 5788:Functional Programming using Standard ML 3234:Nested function and function pointer (C) 2709:When the closure returned by the method 2618:loop, whereas in the Smalltalk example, 231: 5626: 5590: 2007:// specify object module as the closure 173:in 1975, a lexically scoped variant of 4008:Local classes are one of the types of 3206:functionality, but not in syntax. The 991:Here is the same example rewritten in 3796:// It can read final local variables: 3695:) in the lexically enclosing method. 2413:, the superficially similar operator 1558:. An important issue for closures in 988:might be defined in a separate file. 980:, it can use that variable each time 7: 3151:; prints "return from bar" 2863:# prints "return from bar" 809:. Closures are also often used with 652:can be seen to be a closure because 230:(depending on the language; see the 6164:Full documentation can be found at 1730:'inside foo, call to f(): ' 6138:Bengtsson, Joachim (7 July 2010). 5903:. 29 December 1999. Archived from 5461:C++Builder __closure reserved word 5046:// other way to construct delegate 4968:// anonymous delegate construction 3217:Callbacks are used extensively in 1442:Closures can be used to implement 972:The closure is then passed to the 64:, is a technique for implementing 25: 5257:// this is the lambda expression: 3094:; control does not leave bar here 2836:# control does not leave bar here 2732:is captured. An example in Ruby: 2180:, which means captured by value. 664:in the global namespace, not the 533:(bound to the non-local variable 6201:Gafter, Neal (28 January 2007). 6182:: A classic series of papers by 5597:The function may be stored as a 4456:Blocks (C, C++, Objective-C 2.0) 3867:variable just before the class. 1565:Closures are closely related to 6228:: An article about closures in 6063:Joseph D. Darcy's Oracle Weblog 5927:Lambda Expressions and Closures 4319:defined in an enclosing class. 3514:// type of function int->int 3285:// type of function int->int 828:Closures can also be used in a 214:is often used as a synonym for 5963:Foundations of Actor Semantics 3079:"return from lambda" 2908:call-with-current-continuation 2887:, definition and scope of the 2821:"return from lambda" 1608:, which is one such language: 969:inside the lambda expression. 237:For example, in the following 1: 6256:Programming language concepts 5853:. MIT Press. pp. 98–99. 4462:Blocks (C language extension) 2187:functional languages such as 644:This can also be achieved by 5472:Standard C allows writing a 4487:Mac OS X 10.6 "Snow Leopard" 4274:/* increment step omitted */ 4034:/* Define the inner class */ 3654:If executed this now prints 2606:operator and the JavaScript 1468:pointer to the function code 957:appears within the function 145:for evaluating expressions. 119:to support lexically scoped 6117:"Blocks Programming Topics" 6065:. July 2007. Archived from 5977:"Function.prototype.bind()" 5668:10.1007/978-3-642-40447-4_1 5482:using the following syntax: 3103:"return from bar" 2995:"return from foo" 2842:"return from bar" 2791:"return from foo" 1217:object-oriented programming 1186:live on after the function 1077:method instead of a global 6282: 6240:Collection closure methods 6203:"A Definition of Closures" 5152: 4459: 856: 830:continuation-passing style 737:# local x shadows global x 203: 40: 29: 18:Closure (computer science) 6232:imperative languages, by 6119:. Apple Inc. 8 March 2011 5601:to a function, such as a 4692:Delegates (C#, VB.NET, D) 4438:"Hello, world!" 4259:incrementAndReturnCounter 4055:incrementAndReturnCounter 3922:calculateInSeparateThread 3739:calculateInSeparateThread 2986:; control leaves foo here 2785:# control leaves foo here 1458:Implementation and theory 1397:; prints "none" 1254:Closures have many uses: 1238:, and are thus no longer 1071:arrow function expression 177:, and became widespread. 6180:Original "Lambda Papers" 5879:Mozilla Developer Center 5519: 5484: 5344: 5158: 4908: 4804: 4701: 4506: 4336: 4019: 3880: 3697: 3463: 3252: 3227:event-driven programming 3219:graphical user interface 2893: 2797:# Closure using a lambda 2734: 2724:Some languages, such as 2656: 2504: 2420: 2193: 2041: 1872: 1610: 1585:Differences in semantics 1268: 1236:referential transparency 1086: 997: 873: 674: 543: 243: 117:PAL programming language 36:Closure (disambiguation) 5741:10.1145/1093410.1093411 5578:Value-level programming 3240:GNU Compiler Collection 3157:Closure-like constructs 1823:'call to f(): ' 1802:'call to f(): ' 1781:'call to g(): ' 1760:'call to g(): ' 984:calls it. The function 767:# evaluates to 1, not 2 6217:; von der AhĂ©, Peter. 5941:"6.4 Nested Functions" 5786:Wikström, Ă…ke (1987). 5715:10.1093/comjnl/6.4.308 5398:country_at_coordinates 5335:Inline agents (Eiffel) 5123:Function objects (C++) 4232:enclosingClassInstance 4202:enclosingClassInstance 4169:enclosingClassInstance 3453:(and, optionally, the 2740:# Closure using a Proc 2365:is to the computation 1560:concurrent programming 787:functional programming 783:higher-order functions 480:# h(1) is the closure. 450:# f(1) is the closure. 6081:"Inner Class Example" 3673:to be defined inside 2659:"Smalltalk" 2423:"Smalltalk" 1597:bindings of variables 1069:is used to define an 965:variable, which is a 950:In this example, the 865:first-class functions 857:Further information: 853:First-class functions 836:. Constructs such as 204:Further information: 133:in 1964 as having an 121:first-class functions 107:History and etymology 73:first-class functions 50:programming languages 32:Closure (mathematics) 6041:"Lambda Expressions" 5703:The Computer Journal 5513:In a similar way, a 3677:. These are called 2500:"prints 1" 2183:Yet another subset, 2148:Again here variable 2059:getElementsByTagName 1199:State representation 859:First-class function 30:For other uses, see 5907:on 26 December 2008 5841:Sussman, Gerald Jay 5815:Sussman, Gerald Jay 5774:'s Lambda Closures. 5733:ACM SIGSAM Bulletin 5568:Partial application 5478:for a pointer to a 4328:Function<T,U> 3183:Visual Basic (.NET) 2645:(return-from nil x) 2634:(return-from foo x) 2391:escape continuation 1590:Lexical environment 1571:defunctionalization 1499:undefined behaviour 1480:automatic variables 1065:The arrow operator 813:, particularly for 779:first-class objects 333:# Return a closure. 294:# Return a closure. 232:lexical environment 200:Anonymous functions 71:in a language with 6188:Gerald Jay Sussman 6146:on 25 October 2010 6069:on 31 August 2016. 6045:The Java Tutorials 6027:"Nested functions" 5819:Steele, Guy L. Jr. 5499:TMyFunctionPointer 4253:innerClassInstance 4196:innerClassInstance 4014:non-static members 3197:libraries support 2704:"error!" 1579:closure conversion 1495:garbage collection 1228:information hiding 1193:garbage collection 959:best-selling-books 888:best-selling-books 842:control structures 789:languages such as 646:variable shadowing 216:anonymous function 206:Anonymous function 184:also use the term 169:when they defined 101:captured variables 6230:dynamically typed 6184:Guy L. Steele Jr. 5881:. 10 January 2010 5790:. Prentice Hall. 5677:978-3-642-40447-4 5573:Syntactic closure 5144:lambda-expression 5140:the 2011 revision 5130:enables defining 5031:// inner function 4800:Visual Basic .NET 4447:// Will print 13. 3886:CalculationWindow 3855:The capturing of 3703:CalculationWindow 3684:anonymous classes 2154:handle.bind(this) 1503:dangling pointers 1213:private variables 952:lambda expression 228:storage locations 159:closed expression 155:lambda expression 129:defined the term 79:, a closure is a 16:(Redirected from 6273: 6222: 6213:; Gafter, Neal; 6206: 6168: 6162: 6156: 6155: 6153: 6151: 6142:. Archived from 6135: 6129: 6128: 6126: 6124: 6113: 6107: 6106: 6099:"Nested Classes" 6095: 6089: 6088: 6077: 6071: 6070: 6055: 6049: 6048: 6037: 6031: 6030: 6023: 6017: 6016: 6014: 6012: 5998: 5992: 5991: 5989: 5987: 5973: 5967: 5959: 5953: 5952: 5937: 5931: 5923: 5917: 5916: 5914: 5912: 5897: 5891: 5890: 5888: 5886: 5871: 5865: 5864: 5833: 5827: 5826: 5811: 5805: 5804: 5783: 5777: 5776: 5725: 5719: 5718: 5700: 5694:(January 1964). 5688: 5682: 5681: 5657: 5649:Turner, David A. 5645: 5639: 5631: 5615: 5612: 5606: 5603:function pointer 5595: 5541: 5538: 5537:TMyMethodPointer 5535: 5532: 5529: 5526: 5523: 5516: 5509: 5506: 5503: 5500: 5497: 5494: 5491: 5488: 5477: 5468: 5455: 5451: 5443: 5439: 5434: 5430: 5427:the argument to 5423: 5420: 5417: 5414: 5411: 5408: 5405: 5402: 5399: 5396: 5393: 5390: 5387: 5384: 5381: 5378: 5375: 5372: 5369: 5366: 5363: 5360: 5357: 5354: 5351: 5348: 5330: 5327: 5324: 5321: 5318: 5315: 5312: 5309: 5306: 5303: 5300: 5297: 5294: 5291: 5288: 5285: 5282: 5279: 5276: 5273: 5270: 5267: 5264: 5261: 5258: 5255: 5252: 5249: 5246: 5243: 5240: 5237: 5234: 5231: 5228: 5225: 5222: 5219: 5216: 5213: 5210: 5207: 5204: 5201: 5198: 5195: 5192: 5189: 5186: 5183: 5180: 5177: 5174: 5171: 5168: 5165: 5162: 5149: 5137: 5132:function objects 5110: 5107: 5104: 5101: 5098: 5095: 5092: 5089: 5086: 5083: 5080: 5077: 5074: 5071: 5068: 5065: 5062: 5059: 5056: 5053: 5050: 5047: 5044: 5041: 5038: 5035: 5032: 5029: 5026: 5023: 5020: 5017: 5014: 5011: 5008: 5005: 5002: 4999: 4996: 4993: 4990: 4987: 4984: 4981: 4978: 4975: 4972: 4969: 4966: 4963: 4960: 4957: 4954: 4951: 4948: 4945: 4942: 4939: 4936: 4933: 4930: 4927: 4924: 4921: 4918: 4915: 4912: 4898: 4895: 4892: 4889: 4886: 4883: 4880: 4877: 4874: 4871: 4868: 4865: 4862: 4859: 4856: 4853: 4850: 4847: 4844: 4841: 4838: 4835: 4832: 4829: 4826: 4823: 4820: 4817: 4814: 4811: 4808: 4795: 4792: 4789: 4786: 4783: 4780: 4777: 4774: 4771: 4768: 4765: 4762: 4759: 4756: 4753: 4750: 4747: 4744: 4741: 4738: 4735: 4732: 4729: 4726: 4723: 4720: 4717: 4714: 4711: 4708: 4705: 4687: 4684: 4681: 4678: 4675: 4672: 4669: 4666: 4663: 4660: 4657: 4654: 4651: 4648: 4645: 4642: 4639: 4636: 4633: 4630: 4627: 4624: 4621: 4618: 4615: 4612: 4609: 4606: 4603: 4600: 4597: 4594: 4591: 4588: 4585: 4582: 4579: 4576: 4573: 4570: 4567: 4564: 4561: 4558: 4555: 4552: 4549: 4546: 4543: 4540: 4537: 4534: 4531: 4528: 4525: 4522: 4519: 4516: 4513: 4510: 4503: 4499: 4451: 4448: 4445: 4442: 4439: 4436: 4433: 4430: 4427: 4424: 4421: 4418: 4415: 4412: 4409: 4406: 4403: 4400: 4397: 4394: 4391: 4388: 4385: 4382: 4379: 4376: 4373: 4370: 4367: 4364: 4361: 4358: 4355: 4352: 4349: 4346: 4343: 4340: 4333: 4329: 4314: 4311: 4308: 4305: 4302: 4299: 4296: 4293: 4290: 4287: 4284: 4281: 4278: 4275: 4272: 4269: 4266: 4263: 4260: 4257: 4254: 4251: 4248: 4245: 4242: 4239: 4236: 4233: 4230: 4227: 4224: 4221: 4218: 4215: 4212: 4209: 4206: 4203: 4200: 4197: 4194: 4191: 4188: 4185: 4182: 4179: 4176: 4173: 4170: 4167: 4164: 4161: 4158: 4155: 4152: 4149: 4146: 4143: 4140: 4137: 4134: 4131: 4128: 4125: 4122: 4119: 4116: 4113: 4110: 4107: 4104: 4101: 4098: 4095: 4092: 4089: 4086: 4083: 4080: 4077: 4074: 4071: 4068: 4065: 4062: 4059: 4056: 4053: 4050: 4047: 4044: 4041: 4038: 4035: 4032: 4029: 4026: 4023: 4004: 4001: 3998: 3995: 3992: 3989: 3986: 3983: 3980: 3977: 3974: 3971: 3968: 3965: 3962: 3959: 3956: 3953: 3950: 3947: 3944: 3941: 3938: 3935: 3932: 3929: 3926: 3923: 3920: 3917: 3914: 3911: 3908: 3905: 3902: 3899: 3896: 3893: 3890: 3887: 3884: 3873: 3866: 3862: 3858: 3851: 3848: 3845: 3842: 3839: 3836: 3833: 3830: 3827: 3824: 3821: 3818: 3815: 3812: 3809: 3806: 3803: 3800: 3797: 3794: 3791: 3788: 3785: 3782: 3779: 3776: 3773: 3770: 3767: 3764: 3761: 3758: 3755: 3752: 3749: 3746: 3743: 3740: 3737: 3734: 3731: 3728: 3725: 3722: 3719: 3716: 3713: 3710: 3707: 3704: 3701: 3694: 3657: 3650: 3647: 3644: 3641: 3638: 3635: 3632: 3629: 3626: 3623: 3620: 3617: 3614: 3611: 3608: 3605: 3602: 3599: 3596: 3593: 3590: 3587: 3584: 3581: 3578: 3575: 3572: 3569: 3566: 3563: 3560: 3557: 3554: 3551: 3548: 3545: 3542: 3539: 3536: 3533: 3530: 3527: 3524: 3521: 3518: 3515: 3512: 3509: 3506: 3503: 3500: 3497: 3494: 3491: 3488: 3485: 3482: 3479: 3476: 3473: 3470: 3467: 3461:makes it valid: 3460: 3456: 3452: 3445: 3442: 3439: 3436: 3433: 3430: 3427: 3424: 3421: 3418: 3415: 3412: 3409: 3406: 3403: 3400: 3397: 3394: 3391: 3388: 3385: 3382: 3379: 3376: 3373: 3370: 3367: 3364: 3361: 3358: 3355: 3352: 3349: 3346: 3343: 3340: 3337: 3334: 3331: 3328: 3325: 3322: 3319: 3316: 3313: 3310: 3307: 3304: 3301: 3298: 3295: 3292: 3289: 3286: 3283: 3280: 3277: 3274: 3271: 3268: 3265: 3262: 3259: 3256: 3249: 3245: 3209: 3204: 3152: 3149: 3146: 3143: 3140: 3137: 3134: 3131: 3128: 3125: 3122: 3119: 3116: 3113: 3110: 3107: 3104: 3101: 3098: 3095: 3092: 3089: 3086: 3083: 3080: 3077: 3074: 3071: 3068: 3065: 3062: 3059: 3056: 3053: 3050: 3047: 3044: 3041: 3038: 3035: 3032: 3029: 3026: 3023: 3020: 3017: 3014: 3011: 3008: 3005: 3002: 2999: 2996: 2993: 2990: 2987: 2984: 2981: 2978: 2975: 2972: 2969: 2966: 2963: 2960: 2957: 2954: 2951: 2948: 2945: 2942: 2939: 2936: 2933: 2930: 2927: 2924: 2921: 2918: 2915: 2912: 2909: 2906: 2903: 2900: 2897: 2890: 2879: 2875: 2871: 2864: 2861: 2858: 2855: 2852: 2849: 2846: 2843: 2840: 2837: 2834: 2831: 2828: 2825: 2822: 2819: 2816: 2813: 2810: 2807: 2804: 2801: 2798: 2795: 2792: 2789: 2786: 2783: 2780: 2777: 2774: 2771: 2768: 2765: 2762: 2759: 2756: 2753: 2750: 2747: 2744: 2741: 2738: 2731: 2716: 2712: 2705: 2702: 2699: 2696: 2693: 2690: 2687: 2684: 2681: 2678: 2675: 2672: 2669: 2666: 2663: 2660: 2653: 2646: 2642: 2635: 2625: 2621: 2617: 2613: 2609: 2605: 2598: 2595: 2592: 2589: 2586: 2583: 2580: 2577: 2574: 2571: 2568: 2565: 2562: 2559: 2556: 2553: 2550: 2547: 2544: 2541: 2538: 2535: 2532: 2529: 2526: 2523: 2520: 2517: 2514: 2511: 2508: 2501: 2497: 2494: 2491: 2487: 2484: 2481: 2478: 2475: 2472: 2469: 2466: 2463: 2460: 2457: 2454: 2451: 2448: 2445: 2442: 2439: 2436: 2433: 2430: 2427: 2424: 2416: 2408: 2404: 2400: 2396: 2388: 2384: 2380: 2368: 2364: 2360: 2353: 2350: 2347: 2344: 2341: 2338: 2335: 2332: 2329: 2326: 2323: 2320: 2317: 2314: 2311: 2308: 2305: 2302: 2299: 2296: 2293: 2290: 2287: 2284: 2281: 2278: 2275: 2272: 2269: 2266: 2263: 2260: 2257: 2254: 2251: 2248: 2245: 2242: 2239: 2236: 2233: 2230: 2227: 2224: 2221: 2218: 2215: 2212: 2209: 2206: 2203: 2200: 2197: 2179: 2176: 2170: 2159: 2155: 2151: 2144: 2141: 2138: 2135: 2132: 2129: 2126: 2123: 2120: 2117: 2114: 2111: 2108: 2105: 2102: 2099: 2096: 2093: 2090: 2087: 2084: 2081: 2078: 2075: 2072: 2069: 2066: 2063: 2060: 2057: 2054: 2051: 2048: 2045: 2029: 2026: 2023: 2020: 2017: 2014: 2011: 2008: 2005: 2002: 1999: 1996: 1993: 1990: 1987: 1984: 1981: 1978: 1975: 1972: 1969: 1966: 1963: 1960: 1957: 1954: 1951: 1948: 1945: 1942: 1939: 1936: 1933: 1930: 1927: 1924: 1921: 1918: 1915: 1912: 1909: 1906: 1903: 1900: 1897: 1894: 1891: 1888: 1885: 1882: 1879: 1876: 1862: 1855: 1851: 1847: 1843: 1836: 1833: 1830: 1827: 1824: 1821: 1818: 1815: 1812: 1809: 1806: 1803: 1800: 1797: 1794: 1791: 1788: 1785: 1782: 1779: 1776: 1773: 1770: 1767: 1764: 1761: 1758: 1755: 1752: 1749: 1746: 1743: 1740: 1737: 1734: 1731: 1728: 1725: 1722: 1719: 1716: 1713: 1710: 1707: 1704: 1701: 1698: 1695: 1692: 1689: 1686: 1683: 1680: 1677: 1674: 1671: 1668: 1665: 1662: 1659: 1656: 1653: 1650: 1647: 1644: 1641: 1638: 1635: 1632: 1629: 1626: 1623: 1620: 1617: 1614: 1567:function objects 1466:that contains a 1437: 1434: 1431: 1428: 1425: 1422: 1419: 1416: 1413: 1410: 1407: 1404: 1401: 1398: 1395: 1392: 1389: 1386: 1383: 1380: 1377: 1374: 1371: 1368: 1365: 1362: 1359: 1356: 1353: 1350: 1347: 1344: 1341: 1338: 1335: 1332: 1329: 1326: 1323: 1320: 1317: 1314: 1313:"none" 1311: 1308: 1305: 1302: 1299: 1296: 1293: 1290: 1287: 1284: 1281: 1278: 1275: 1272: 1221:function objects 1189: 1185: 1181: 1174: 1171: 1168: 1165: 1162: 1159: 1156: 1153: 1150: 1147: 1144: 1141: 1138: 1135: 1132: 1129: 1126: 1123: 1120: 1117: 1114: 1111: 1108: 1105: 1102: 1099: 1096: 1093: 1090: 1080: 1076: 1068: 1061: 1058: 1055: 1052: 1049: 1046: 1043: 1040: 1037: 1034: 1031: 1028: 1025: 1022: 1019: 1016: 1013: 1010: 1007: 1006:bestSellingBooks 1004: 1001: 987: 983: 979: 975: 964: 960: 956: 946: 943: 940: 937: 934: 931: 928: 925: 922: 919: 916: 913: 910: 907: 904: 901: 898: 895: 892: 889: 886: 883: 880: 877: 823:dynamic web page 768: 765: 762: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 671: 667: 663: 660:is bound to the 659: 655: 651: 637: 634: 631: 628: 625: 622: 619: 616: 613: 610: 607: 604: 601: 598: 595: 592: 589: 586: 583: 580: 577: 574: 571: 568: 565: 562: 559: 556: 553: 550: 547: 540: 536: 532: 516: 512: 508: 504: 500: 492: 488: 481: 478: 475: 472: 469: 466: 463: 460: 457: 454: 451: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 418: 415: 412: 409: 406: 403: 400: 397: 394: 391: 388: 385: 382: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 346: 343: 340: 337: 334: 331: 328: 325: 322: 319: 316: 313: 310: 307: 304: 301: 298: 295: 292: 289: 286: 283: 280: 277: 274: 271: 268: 265: 262: 259: 256: 253: 250: 247: 234:section below). 135:environment part 66:lexically scoped 62:function closure 21: 6281: 6280: 6276: 6275: 6274: 6272: 6271: 6270: 6246: 6245: 6209: 6200: 6176: 6171: 6163: 6159: 6149: 6147: 6137: 6136: 6132: 6122: 6120: 6115: 6114: 6110: 6097: 6096: 6092: 6079: 6078: 6074: 6057: 6056: 6052: 6039: 6038: 6034: 6025: 6024: 6020: 6010: 6008: 6000: 5999: 5995: 5985: 5983: 5975: 5974: 5970: 5960: 5956: 5939: 5938: 5934: 5924: 5920: 5910: 5908: 5899: 5898: 5894: 5884: 5882: 5873: 5872: 5868: 5861: 5837:Abelson, Harold 5835: 5834: 5830: 5813: 5812: 5808: 5798: 5785: 5784: 5780: 5727: 5726: 5722: 5698: 5690: 5689: 5685: 5678: 5655: 5647: 5646: 5642: 5632: 5628: 5624: 5619: 5618: 5613: 5609: 5596: 5592: 5587: 5582: 5563:Lambda calculus 5553:Command pattern 5548: 5543: 5542: 5539: 5536: 5533: 5530: 5527: 5524: 5521: 5514: 5511: 5510: 5507: 5504: 5501: 5498: 5495: 5492: 5489: 5486: 5473: 5466: 5463: 5453: 5449: 5441: 5437: 5432: 5428: 5425: 5424: 5421: 5418: 5415: 5412: 5409: 5406: 5403: 5400: 5397: 5394: 5391: 5388: 5385: 5382: 5379: 5376: 5373: 5370: 5367: 5364: 5361: 5358: 5355: 5352: 5349: 5346: 5337: 5332: 5331: 5328: 5325: 5322: 5319: 5316: 5313: 5310: 5307: 5304: 5301: 5298: 5295: 5292: 5289: 5286: 5283: 5280: 5277: 5274: 5271: 5268: 5265: 5262: 5259: 5256: 5253: 5250: 5247: 5244: 5241: 5238: 5235: 5232: 5229: 5226: 5223: 5220: 5217: 5214: 5211: 5208: 5205: 5202: 5199: 5196: 5193: 5190: 5187: 5184: 5181: 5178: 5175: 5172: 5169: 5166: 5163: 5160: 5157: 5147: 5135: 5134:by overloading 5125: 5112: 5111: 5108: 5105: 5102: 5099: 5096: 5093: 5090: 5087: 5084: 5081: 5078: 5075: 5072: 5069: 5066: 5063: 5060: 5057: 5054: 5051: 5048: 5045: 5042: 5039: 5036: 5033: 5030: 5027: 5024: 5021: 5018: 5015: 5012: 5009: 5006: 5003: 5000: 4997: 4994: 4991: 4988: 4985: 4982: 4979: 4976: 4973: 4970: 4967: 4964: 4961: 4958: 4955: 4952: 4949: 4946: 4943: 4940: 4937: 4934: 4931: 4928: 4925: 4922: 4919: 4916: 4913: 4910: 4900: 4899: 4896: 4893: 4890: 4887: 4884: 4881: 4878: 4875: 4872: 4869: 4866: 4863: 4860: 4857: 4854: 4851: 4848: 4845: 4842: 4839: 4836: 4833: 4830: 4827: 4824: 4821: 4818: 4815: 4812: 4809: 4806: 4797: 4796: 4793: 4790: 4787: 4784: 4781: 4778: 4775: 4772: 4769: 4766: 4763: 4760: 4757: 4754: 4751: 4748: 4745: 4742: 4739: 4736: 4733: 4730: 4727: 4724: 4721: 4718: 4715: 4712: 4709: 4706: 4703: 4694: 4689: 4688: 4685: 4682: 4679: 4677:@"%d" 4676: 4673: 4670: 4667: 4664: 4661: 4659:@"%d" 4658: 4655: 4652: 4649: 4646: 4643: 4641:@"%d" 4640: 4637: 4634: 4631: 4628: 4625: 4622: 4619: 4616: 4613: 4610: 4607: 4604: 4601: 4598: 4595: 4592: 4589: 4586: 4583: 4580: 4577: 4574: 4571: 4568: 4565: 4562: 4559: 4556: 4553: 4550: 4547: 4544: 4541: 4538: 4535: 4532: 4529: 4526: 4523: 4520: 4517: 4514: 4511: 4508: 4501: 4497: 4483:Objective-C 2.0 4464: 4458: 4453: 4452: 4449: 4446: 4443: 4440: 4437: 4434: 4431: 4428: 4425: 4422: 4419: 4416: 4413: 4410: 4407: 4404: 4401: 4398: 4395: 4392: 4389: 4386: 4383: 4380: 4377: 4374: 4371: 4368: 4365: 4362: 4359: 4356: 4353: 4350: 4347: 4344: 4341: 4338: 4331: 4327: 4316: 4315: 4312: 4309: 4306: 4303: 4300: 4297: 4294: 4291: 4288: 4285: 4282: 4279: 4276: 4273: 4270: 4267: 4264: 4261: 4258: 4255: 4252: 4249: 4246: 4243: 4240: 4237: 4234: 4231: 4228: 4225: 4222: 4219: 4216: 4213: 4210: 4207: 4204: 4201: 4198: 4195: 4192: 4189: 4186: 4183: 4180: 4177: 4174: 4171: 4168: 4165: 4162: 4159: 4156: 4153: 4150: 4147: 4144: 4141: 4138: 4135: 4132: 4129: 4126: 4123: 4120: 4117: 4114: 4111: 4108: 4105: 4102: 4099: 4096: 4093: 4090: 4087: 4084: 4081: 4078: 4075: 4072: 4069: 4066: 4063: 4060: 4057: 4054: 4051: 4048: 4045: 4042: 4039: 4036: 4033: 4030: 4027: 4024: 4021: 4006: 4005: 4002: 3999: 3996: 3993: 3990: 3987: 3984: 3981: 3978: 3975: 3972: 3969: 3966: 3963: 3960: 3957: 3954: 3951: 3948: 3945: 3942: 3939: 3936: 3933: 3930: 3927: 3924: 3921: 3918: 3915: 3912: 3909: 3906: 3903: 3900: 3897: 3894: 3891: 3888: 3885: 3882: 3871: 3864: 3860: 3856: 3853: 3852: 3849: 3846: 3843: 3840: 3837: 3834: 3831: 3828: 3825: 3822: 3819: 3816: 3813: 3810: 3807: 3804: 3801: 3798: 3795: 3792: 3789: 3786: 3783: 3780: 3777: 3774: 3771: 3768: 3765: 3762: 3759: 3756: 3753: 3750: 3747: 3744: 3741: 3738: 3735: 3732: 3729: 3726: 3723: 3720: 3717: 3714: 3711: 3708: 3705: 3702: 3699: 3692: 3664: 3655: 3652: 3651: 3648: 3645: 3642: 3639: 3636: 3633: 3630: 3627: 3624: 3621: 3618: 3615: 3612: 3609: 3606: 3603: 3600: 3597: 3594: 3591: 3588: 3585: 3582: 3579: 3576: 3573: 3570: 3567: 3564: 3561: 3558: 3555: 3552: 3549: 3546: 3543: 3540: 3537: 3534: 3531: 3528: 3525: 3522: 3519: 3516: 3513: 3510: 3507: 3504: 3501: 3498: 3495: 3492: 3489: 3486: 3483: 3480: 3477: 3474: 3471: 3469:<stdio.h> 3468: 3465: 3458: 3454: 3450: 3447: 3446: 3443: 3440: 3437: 3434: 3431: 3428: 3425: 3422: 3419: 3416: 3413: 3410: 3407: 3404: 3401: 3398: 3395: 3392: 3389: 3386: 3383: 3380: 3377: 3374: 3371: 3368: 3365: 3362: 3359: 3356: 3353: 3350: 3347: 3344: 3341: 3338: 3335: 3332: 3329: 3326: 3323: 3320: 3317: 3314: 3311: 3308: 3305: 3302: 3299: 3296: 3293: 3290: 3287: 3284: 3281: 3278: 3275: 3272: 3269: 3266: 3263: 3260: 3258:<stdio.h> 3257: 3254: 3247: 3243: 3236: 3223:widget toolkits 3210:pointer is not 3207: 3202: 3191: 3159: 3154: 3153: 3150: 3147: 3144: 3141: 3138: 3135: 3132: 3129: 3126: 3123: 3120: 3117: 3114: 3111: 3108: 3105: 3102: 3099: 3096: 3093: 3090: 3087: 3084: 3081: 3078: 3075: 3072: 3069: 3066: 3063: 3060: 3057: 3054: 3051: 3048: 3045: 3042: 3039: 3036: 3033: 3030: 3027: 3024: 3021: 3018: 3015: 3012: 3009: 3006: 3003: 3000: 2997: 2994: 2991: 2988: 2985: 2982: 2979: 2976: 2973: 2970: 2967: 2964: 2961: 2958: 2955: 2952: 2949: 2946: 2943: 2940: 2937: 2934: 2931: 2928: 2925: 2922: 2919: 2916: 2913: 2910: 2907: 2904: 2901: 2898: 2895: 2888: 2877: 2873: 2869: 2866: 2865: 2862: 2859: 2856: 2853: 2850: 2847: 2844: 2841: 2838: 2835: 2832: 2829: 2826: 2823: 2820: 2817: 2814: 2811: 2808: 2805: 2802: 2799: 2796: 2793: 2790: 2787: 2784: 2781: 2778: 2775: 2772: 2769: 2766: 2763: 2760: 2757: 2754: 2751: 2748: 2745: 2742: 2739: 2736: 2729: 2719:spaghetti stack 2714: 2710: 2707: 2706: 2703: 2700: 2697: 2694: 2691: 2688: 2685: 2682: 2679: 2676: 2673: 2670: 2667: 2664: 2661: 2658: 2651: 2644: 2640: 2633: 2623: 2619: 2615: 2611: 2607: 2603: 2600: 2599: 2596: 2593: 2590: 2587: 2584: 2581: 2578: 2575: 2572: 2569: 2566: 2563: 2560: 2557: 2554: 2551: 2548: 2545: 2542: 2539: 2536: 2533: 2530: 2527: 2524: 2521: 2518: 2515: 2512: 2509: 2506: 2503: 2502: 2499: 2495: 2492: 2489: 2485: 2482: 2479: 2476: 2473: 2470: 2467: 2464: 2461: 2458: 2455: 2452: 2449: 2446: 2443: 2440: 2437: 2434: 2431: 2428: 2425: 2422: 2414: 2406: 2402: 2398: 2394: 2386: 2382: 2378: 2375: 2373:Closure leaving 2366: 2362: 2358: 2357:The binding of 2355: 2354: 2351: 2348: 2345: 2342: 2339: 2336: 2333: 2330: 2327: 2324: 2321: 2318: 2315: 2312: 2309: 2306: 2303: 2300: 2297: 2294: 2291: 2288: 2285: 2282: 2279: 2276: 2273: 2270: 2267: 2264: 2261: 2258: 2255: 2252: 2249: 2246: 2243: 2240: 2237: 2234: 2231: 2228: 2225: 2222: 2219: 2216: 2213: 2210: 2207: 2204: 2201: 2198: 2195: 2178: 2175: 2168: 2157: 2153: 2149: 2146: 2145: 2142: 2139: 2136: 2133: 2130: 2127: 2124: 2121: 2118: 2115: 2112: 2109: 2106: 2103: 2100: 2097: 2094: 2091: 2088: 2085: 2082: 2079: 2076: 2073: 2070: 2067: 2064: 2061: 2058: 2055: 2052: 2049: 2046: 2043: 2036: 2031: 2030: 2027: 2024: 2021: 2018: 2015: 2012: 2009: 2006: 2003: 2000: 1997: 1994: 1991: 1988: 1985: 1982: 1979: 1976: 1973: 1970: 1967: 1964: 1961: 1958: 1955: 1952: 1949: 1946: 1943: 1940: 1937: 1934: 1931: 1928: 1925: 1922: 1919: 1916: 1913: 1910: 1907: 1904: 1901: 1898: 1895: 1892: 1889: 1886: 1883: 1880: 1877: 1874: 1869: 1861:Function.bind() 1860: 1853: 1849: 1845: 1841: 1838: 1837: 1834: 1831: 1828: 1825: 1822: 1819: 1816: 1813: 1810: 1807: 1804: 1801: 1798: 1795: 1792: 1789: 1786: 1783: 1780: 1777: 1774: 1771: 1768: 1765: 1762: 1759: 1756: 1753: 1750: 1747: 1744: 1741: 1738: 1735: 1732: 1729: 1726: 1723: 1720: 1717: 1714: 1711: 1708: 1705: 1702: 1699: 1696: 1693: 1690: 1687: 1684: 1681: 1678: 1675: 1672: 1669: 1666: 1663: 1660: 1657: 1654: 1651: 1648: 1645: 1642: 1639: 1636: 1633: 1630: 1627: 1624: 1621: 1618: 1615: 1612: 1592: 1587: 1543:, which has an 1520:heap allocation 1488:heap allocation 1460: 1439: 1438: 1435: 1432: 1429: 1426: 1423: 1420: 1417: 1414: 1411: 1408: 1405: 1402: 1399: 1396: 1393: 1390: 1387: 1384: 1381: 1378: 1375: 1372: 1369: 1366: 1363: 1360: 1357: 1354: 1351: 1348: 1345: 1342: 1339: 1336: 1333: 1330: 1327: 1324: 1321: 1318: 1315: 1312: 1309: 1306: 1303: 1300: 1297: 1294: 1291: 1288: 1285: 1282: 1279: 1276: 1273: 1270: 1252: 1201: 1187: 1183: 1179: 1176: 1175: 1172: 1169: 1166: 1163: 1160: 1157: 1154: 1151: 1148: 1145: 1142: 1139: 1136: 1133: 1130: 1127: 1124: 1121: 1118: 1115: 1112: 1109: 1106: 1103: 1100: 1097: 1094: 1091: 1088: 1078: 1074: 1066: 1063: 1062: 1059: 1056: 1053: 1050: 1047: 1044: 1041: 1038: 1035: 1032: 1029: 1026: 1023: 1020: 1017: 1014: 1011: 1008: 1005: 1002: 999: 985: 981: 977: 973: 962: 958: 954: 948: 947: 944: 941: 938: 935: 932: 929: 926: 923: 920: 917: 914: 911: 908: 905: 902: 899: 896: 893: 890: 887: 884: 881: 878: 875: 861: 855: 775: 770: 769: 766: 763: 760: 757: 754: 751: 748: 745: 742: 739: 736: 733: 730: 727: 724: 721: 718: 715: 712: 709: 706: 703: 700: 697: 694: 691: 688: 685: 682: 679: 676: 669: 665: 661: 657: 656:in the body of 653: 649: 639: 638: 635: 632: 629: 626: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 538: 534: 530: 514: 510: 506: 502: 498: 495:nested function 490: 486: 483: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 371: 368: 365: 362: 359: 356: 353: 350: 347: 344: 341: 338: 335: 332: 329: 326: 323: 320: 317: 314: 311: 308: 305: 302: 299: 296: 293: 290: 287: 284: 281: 278: 275: 272: 269: 266: 263: 260: 257: 254: 251: 248: 245: 208: 202: 194:mathematics use 141:as used by his 109: 58:lexical closure 46: 39: 28: 23: 22: 15: 12: 11: 5: 6279: 6277: 6269: 6268: 6263: 6258: 6248: 6247: 6244: 6243: 6237: 6223: 6215:Gosling, James 6207: 6198: 6175: 6174:External links 6172: 6170: 6169: 6157: 6130: 6108: 6090: 6072: 6050: 6032: 6018: 5993: 5968: 5954: 5932: 5918: 5892: 5875:"array.filter" 5866: 5859: 5845:Sussman, Julie 5828: 5806: 5796: 5778: 5720: 5709:(4): 308–320. 5683: 5676: 5640: 5625: 5623: 5620: 5617: 5616: 5607: 5589: 5588: 5586: 5583: 5581: 5580: 5575: 5570: 5565: 5560: 5555: 5549: 5547: 5544: 5520: 5485: 5462: 5459: 5345: 5336: 5333: 5159: 5153:Main article: 5124: 5121: 4909: 4805: 4702: 4693: 4690: 4507: 4460:Main article: 4457: 4454: 4337: 4187:EnclosingClass 4178:EnclosingClass 4166:EnclosingClass 4028:EnclosingClass 4020: 3881: 3698: 3687:(or anonymous 3663: 3660: 3464: 3253: 3235: 3232: 3190: 3187: 3158: 3155: 2894: 2735: 2657: 2505: 2421: 2374: 2371: 2194: 2042: 2039:the for loop. 2035: 2032: 1873: 1868: 1865: 1611: 1591: 1588: 1586: 1583: 1575:lambda lifting 1507:funarg problem 1464:data structure 1459: 1456: 1448: 1447: 1376:secret-message 1349:secret-message 1310:secret-message 1269: 1267: 1266: 1263: 1251: 1248: 1240:pure functions 1200: 1197: 1087: 998: 874: 854: 851: 815:event handlers 774: 771: 675: 544: 485:the values of 244: 201: 198: 190:data structure 153:to refer to a 108: 105: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 6278: 6267: 6264: 6262: 6259: 6257: 6254: 6253: 6251: 6241: 6238: 6235: 6234:Martin Fowler 6231: 6227: 6224: 6220: 6216: 6212: 6211:Bracha, Gilad 6208: 6204: 6199: 6196: 6194: 6189: 6185: 6181: 6178: 6177: 6173: 6167: 6161: 6158: 6145: 6141: 6134: 6131: 6118: 6112: 6109: 6104: 6100: 6094: 6091: 6086: 6082: 6076: 6073: 6068: 6064: 6060: 6054: 6051: 6046: 6042: 6036: 6033: 6028: 6022: 6019: 6007: 6003: 5997: 5994: 5982: 5978: 5972: 5969: 5965: 5964: 5958: 5955: 5951: 5946: 5942: 5936: 5933: 5929: 5928: 5922: 5919: 5906: 5902: 5896: 5893: 5880: 5876: 5870: 5867: 5862: 5860:0-262-51087-1 5856: 5852: 5851: 5846: 5842: 5838: 5832: 5829: 5824: 5820: 5816: 5810: 5807: 5803: 5799: 5797:0-13-331968-7 5793: 5789: 5782: 5779: 5775: 5773: 5769: 5762: 5758: 5754: 5750: 5746: 5742: 5738: 5735:(15): 13–27. 5734: 5730: 5724: 5721: 5716: 5712: 5708: 5704: 5697: 5693: 5687: 5684: 5679: 5673: 5669: 5665: 5661: 5654: 5650: 5644: 5641: 5637: 5630: 5627: 5621: 5611: 5608: 5604: 5600: 5594: 5591: 5584: 5579: 5576: 5574: 5571: 5569: 5566: 5564: 5561: 5559: 5556: 5554: 5551: 5550: 5545: 5518: 5483: 5481: 5480:function type 5476: 5470: 5460: 5458: 5445: 5343: 5341: 5334: 5156: 5151: 5145: 5141: 5133: 5129: 5122: 5120: 5116: 4907: 4905: 4803: 4801: 4700: 4698: 4691: 4505: 4494: 4492: 4488: 4484: 4480: 4476: 4472: 4468: 4463: 4455: 4335: 4325: 4320: 4018: 4015: 4011: 3879: 3876: 3868: 3696: 3690: 3686: 3685: 3680: 3679:local classes 3676: 3672: 3668: 3661: 3659: 3658:as expected. 3589:fn_int_to_int 3517:fn_int_to_int 3502:fn_int_to_int 3462: 3384:fn_int_to_int 3288:fn_int_to_int 3273:fn_int_to_int 3251: 3241: 3233: 3231: 3228: 3225:to implement 3224: 3220: 3215: 3213: 3200: 3196: 3189:Callbacks (C) 3188: 3186: 3184: 3180: 3176: 3172: 3168: 3164: 3156: 2892: 2886: 2881: 2733: 2727: 2722: 2720: 2655: 2650: 2643:, while Lisp 2639: 2631: 2627: 2507:// ECMAScript 2419: 2412: 2392: 2372: 2370: 2192: 2190: 2186: 2181: 2172: 2166: 2161: 2040: 2033: 1871: 1866: 1864: 1857: 1613:// Javascript 1609: 1607: 1602: 1598: 1589: 1584: 1582: 1580: 1576: 1572: 1568: 1563: 1561: 1557: 1556:acquaintances 1553: 1548: 1546: 1542: 1538: 1534: 1532: 1529: 1524: 1521: 1516: 1512: 1508: 1504: 1500: 1496: 1491: 1489: 1485: 1481: 1476: 1473: 1469: 1465: 1457: 1455: 1453: 1445: 1441: 1440: 1264: 1261: 1257: 1256: 1255: 1249: 1247: 1245: 1241: 1237: 1233: 1229: 1224: 1222: 1218: 1214: 1210: 1206: 1198: 1196: 1194: 1085: 1082: 1072: 996: 994: 989: 970: 968: 967:free variable 953: 872: 870: 866: 860: 852: 850: 848: 843: 839: 835: 831: 826: 824: 820: 817:, such as in 816: 812: 808: 804: 800: 796: 792: 788: 784: 780: 772: 673: 647: 642: 542: 526: 522: 518: 496: 242: 240: 235: 233: 229: 225: 221: 217: 213: 207: 199: 197: 195: 191: 187: 183: 178: 176: 172: 168: 164: 160: 156: 152: 148: 144: 140: 136: 132: 128: 124: 122: 118: 114: 106: 104: 102: 98: 94: 90: 89:free variable 86: 82: 78: 77:Operationally 74: 70: 67: 63: 59: 55: 51: 44: 37: 33: 19: 6191: 6160: 6150:18 September 6148:. Retrieved 6144:the original 6133: 6121:. Retrieved 6111: 6102: 6093: 6084: 6075: 6067:the original 6062: 6053: 6044: 6035: 6021: 6009:. Retrieved 6006:MDN Web Docs 6005: 5996: 5984:. Retrieved 5981:MDN Web Docs 5980: 5971: 5961: 5957: 5948: 5944: 5935: 5925: 5921: 5909:. Retrieved 5905:the original 5895: 5883:. Retrieved 5878: 5869: 5849: 5831: 5809: 5801: 5787: 5781: 5764: 5732: 5723: 5706: 5702: 5692:Landin, P.J. 5686: 5659: 5643: 5629: 5610: 5593: 5512: 5471: 5464: 5446: 5426: 5338: 5143: 5126: 5117: 5113: 4901: 4798: 4695: 4495: 4465: 4321: 4317: 4013: 4007: 3877: 3869: 3854: 3688: 3682: 3678: 3665: 3653: 3448: 3237: 3216: 3192: 3160: 2882: 2867: 2723: 2708: 2628: 2601: 2376: 2356: 2182: 2173: 2162: 2147: 2037: 1870: 1858: 1839: 1593: 1564: 1555: 1549: 1539: 1535: 1527: 1525: 1492: 1482:on a linear 1477: 1461: 1449: 1253: 1225: 1202: 1177: 1083: 1075:Array.filter 1064: 990: 971: 949: 862: 827: 776: 773:Applications 643: 640: 527: 523: 519: 484: 236: 211: 209: 185: 180:Sussman and 179: 158: 150: 143:SECD machine 139:control part 138: 134: 130: 127:Peter Landin 125: 110: 100: 69:name binding 61: 57: 53: 47: 6266:Subroutines 6195:expressions 6011:20 November 5986:20 November 5911:23 December 5749:1721.1/5854 5729:Moses, Joel 5433:click_event 5353:click_event 4623:downCounter 4605:autorelease 4530:downCounter 4469:introduced 4332:.apply(T t) 4010:inner class 3449:But moving 3179:Objective-C 2880:statement. 2647:behaves as 2636:behaves as 2630:Common Lisp 2597:// prints 0 2496:printString 2065:'a' 2028:// emits 42 1989:unboundGetX 1968:unboundGetX 1938:unboundGetX 1577:; see also 1552:Actor model 6250:Categories 6002:"Closures" 5945:GCC Manual 5885:9 February 5636:Wikisource 5622:References 5293:&& 5148:operator() 5136:operator() 4894:multiplier 4846:multiplier 4791:multiplier 4746:multiplier 4238:getCounter 4211:InnerClass 4193:InnerClass 4118:getCounter 4043:InnerClass 2649:JavaScript 2483:Transcript 2301:Fractional 2205:Fractional 2196:-- Haskell 1835:// 2 (++x) 1814:// 1 (++x) 1793:// 0 (--x) 1772:// 1 (--x) 1606:ECMAScript 1250:Other uses 1188:derivative 1098:derivative 993:JavaScript 927:book-sales 871:function: 834:hide state 819:JavaScript 525:function. 147:Joel Moses 113:λ-calculus 83:storing a 5599:reference 5531:__closure 5467:__closure 5429:subscribe 5359:subscribe 5347:ok_button 3961:calculate 3799:calculate 3212:type safe 3199:callbacks 2638:Smalltalk 2411:Smalltalk 2160:keyword. 2022:boundGetX 1983:boundGetX 1840:Function 1515:delegates 1501:, due to 1260:Smalltalk 1073:, and an 1054:threshold 1012:threshold 978:threshold 963:threshold 942:book-list 936:threshold 891:threshold 811:callbacks 668:local to 210:The term 97:reference 6226:Closures 5847:(1996). 5757:17514262 5651:(2012). 5558:Currying 5546:See also 4941:delegate 4876:Function 4614:IntBlock 4527:IntBlock 4521:IntBlock 4366:Function 3901:volatile 3775:Runnable 3718:volatile 3669:enables 3616:"%d 3466:#include 3411:"%d 3255:#include 2896:; Scheme 2870:Proc.new 2652:return x 2612:return x 2546:function 2510:function 2399:continue 2387:continue 2110:function 2089:elements 2053:document 2047:elements 1905:function 1688:function 1658:function 1631:function 1601:variable 1446:systems. 1095:function 1024:bookList 1003:function 847:run-time 85:function 6123:8 March 5823:AI Memo 5761:AI Memo 5522:typedef 5515:typedef 5487:typedef 5475:typedef 5450:Current 5416:display 5383:INTEGER 5227:find_if 4548:__block 4509:typedef 4502:__block 4485:and in 4420:println 4378:Integer 4295:println 4130:counter 4097:counter 4088:counter 4082:private 4067:counter 3898:private 3889:extends 3715:private 3706:extends 3675:methods 3671:classes 3490:typedef 3455:typedef 3261:typedef 3238:With a 3139:display 3130:newline 3112:display 3055:call/cc 3019:call/cc 2932:call/cc 2905:call/cc 2616:forEach 2540:forEach 2367:(x / y) 2189:Haskell 2156:or the 2104:onclick 2010:console 1956:console 1452:lexical 1424:display 1403:newline 1385:display 1205:private 838:objects 220:literal 212:closure 186:closure 182:Abelson 163:Sussman 151:closure 131:closure 56:, also 54:closure 43:Clojure 6193:lambda 5857:  5794:  5755:  5674:  5340:Eiffel 5290:myname 5281:return 5266:string 5209:// ... 5197:string 5191:vector 5173:myname 5170:string 5034:return 5013:return 4950:return 4938:return 4870:Select 4858:result 4773:Select 4761:result 4584:return 4566:return 4471:blocks 4426:length 4408:System 4402:length 4384:length 4372:String 4354:String 4342:static 4339:public 4324:Java 8 4322:As of 4283:System 4154:String 4142:static 4139:public 4127:return 4112:public 4064:return 4049:public 4037:public 4022:public 3979:result 3973:result 3949:Thread 3916:public 3913:// ... 3907:result 3892:JFrame 3820:result 3814:result 3766:Thread 3733:public 3730:// ... 3724:result 3709:JFrame 3640:return 3622:" 3610:printf 3577:return 3568:number 3559:return 3529:number 3435:return 3417:" 3405:printf 3348:return 3339:number 3330:return 3300:number 3221:(GUI) 3181:, and 3100:return 3076:return 3067:return 3061:lambda 3040:define 3031:return 3025:lambda 3004:define 2992:return 2968:return 2953:define 2944:return 2938:lambda 2917:define 2902:define 2889:return 2885:Scheme 2878:return 2874:lambda 2839:return 2818:return 2812:lambda 2788:return 2767:return 2737:# Ruby 2730:return 2698:value: 2608:return 2573:return 2561:return 2407:return 2403:return 2379:return 2113:handle 2001:module 1944:module 1914:return 1878:module 1697:return 1667:return 1541:Scheme 1531:Erlang 1444:object 1370:lambda 1331:lambda 1289:define 1274:define 1244:Scheme 1232:extent 1119:return 1079:filter 1030:filter 1021:return 986:filter 982:filter 974:filter 906:lambda 900:filter 882:define 869:Scheme 805:, and 803:Python 740:return 701:return 612:lambda 576:return 515:lambda 453:assert 423:assert 399:assert 378:assert 315:lambda 312:return 288:return 276:return 241:code: 239:Python 171:Scheme 167:Steele 137:and a 81:record 5772:ISWIM 5763:199. 5753:S2CID 5699:(PDF) 5656:(PDF) 5585:Notes 5365:agent 5269:& 5263:const 5239:begin 5094:test2 5073:test1 5037:& 4977:test2 4914:test1 4782:=> 4671:NSLog 4653:NSLog 4635:NSLog 4560:start 4539:start 4491:iOS 4 4467:Apple 4432:apply 4393:-> 4040:class 4025:class 3994:start 3955:-> 3928:final 3883:class 3872:final 3865:final 3861:final 3857:final 3841:start 3745:final 3700:class 3693:final 3689:inner 3628:add10 3598:adder 3592:add10 3562:value 3550:value 3520:adder 3457:) in 3451:adder 3423:add10 3393:adder 3387:add10 3351:& 3333:value 3321:value 3291:adder 3244:adder 3208:void* 3203:void* 3193:Some 2868:Both 2585:alert 2486:show: 2395:break 2383:break 2340:print 2313:-> 2307:=> 2277:where 2262:-> 2232:-> 2223:-> 2217:-> 2211:=> 2169:final 2122:alert 1817:alert 1796:alert 1775:alert 1754:alert 1724:alert 1545:ALGOL 1484:stack 1472:binds 1209:scope 1125:=> 1067:=> 1051:>= 1048:sales 1039:=> 921:>= 799:Julia 224:value 93:value 6186:and 6152:2010 6125:2011 6013:2018 5988:2018 5913:2008 5887:2010 5855:ISBN 5825:349. 5792:ISBN 5770:and 5768:LISP 5672:ISBN 5540:)(); 5525:void 5505:void 5490:void 5454:this 5440:and 5308:> 5302:size 5212:auto 5200:> 5194:< 5161:void 5064:auto 5052:void 4974:auto 4911:auto 4864:data 4810:data 4767:data 4707:data 4686:()); 4668:()); 4650:()); 4599:copy 4524:)(); 4489:and 4381:> 4369:< 4357:args 4348:main 4345:void 4265:< 4157:args 4148:main 4145:void 3919:void 3784:void 3736:void 3667:Java 3481:void 3475:main 3459:main 3375:void 3369:main 3175:Java 3106:)))) 3082:)))) 2998:)))) 2872:and 2857:puts 2848:puts 2833:call 2782:call 2755:Proc 2726:Ruby 2686:self 2594:()); 2490:self 2397:and 2385:and 2334:main 2185:lazy 2025:()); 1995:bind 1971:()); 1950:getX 1917:this 1899:getX 1848:and 1832:()); 1811:()); 1790:()); 1769:()); 1751:// 2 1739:()); 1528:e.g. 1361:set! 1346:set! 1322:set! 1182:and 1042:book 1036:book 930:book 912:book 840:and 807:Rust 793:and 791:Lisp 633:nums 600:nums 555:nums 505:and 489:and 175:Lisp 165:and 52:, a 34:and 5745:hdl 5737:doi 5711:doi 5664:doi 5419:end 5392:map 5254:(), 5251:end 5242:(), 5221:std 5182:int 5164:foo 5128:C++ 5103:(); 5097:(); 5082:(); 5076:(); 5055:bar 5040:foo 5004:foo 5001:int 4986:int 4923:int 4902:In 4855:Dim 4843:Dim 4807:Dim 4758:var 4743:var 4713:new 4704:var 4575:int 4551:int 4536:int 4512:int 4479:C++ 4414:out 4405:(); 4289:out 4262:()) 4241:(); 4223:int 4217:for 4214:(); 4208:new 4181:(); 4175:new 4115:int 4085:int 4052:int 3997:(); 3991:}). 3967:uri 3952:(() 3946:new 3934:uri 3931:URI 3904:int 3844:(); 3805:uri 3787:run 3772:new 3763:new 3751:uri 3748:URI 3721:int 3637:)); 3580:add 3547:int 3541:add 3538:int 3526:int 3508:int 3493:int 3472:int 3432:)); 3366:int 3354:add 3318:int 3312:add 3309:int 3297:int 3279:int 3264:int 3250:): 3248:-O0 3163:C++ 3145:bar 3118:foo 3010:bar 2923:foo 2883:In 2860:bar 2851:foo 2845:end 2803:bar 2800:def 2794:end 2761:new 2746:foo 2743:def 2715:foo 2711:foo 2701:123 2689:foo 2668:bar 2662:foo 2624:foo 2591:foo 2570:}); 2522:var 2513:foo 2493:foo 2480:bar 2468:do: 2432:xs 2426:foo 2363:foo 2349:123 2325:foo 2241:foo 2199:foo 2158:let 2080:var 2074:for 2044:var 2016:log 1980:var 1962:log 1935:var 1875:var 1842:foo 1748:(); 1745:foo 1643:var 1634:foo 1616:var 1573:or 1430:bar 1412:foo 1391:bar 1379:))) 1364:bar 1355:))) 1352:msg 1337:msg 1325:foo 1304:let 1292:bar 1277:foo 1215:in 832:to 713:def 686:def 606:map 588:map 561:def 297:def 261:def 246:def 95:or 60:or 48:In 6252:: 6197:). 6101:. 6083:. 6061:. 6043:. 6004:. 5979:. 5947:. 5943:. 5877:. 5843:; 5839:; 5817:; 5800:. 5759:. 5751:. 5743:. 5705:. 5701:. 5670:. 5658:. 5508:); 5502:)( 5444:. 5413:). 5389:do 5320:); 5305:() 5287:!= 5224::: 5100:dg 5088:dg 5079:dg 5067:dg 5058:() 5007:() 4995:20 4980:() 4965:}; 4944:() 4917:() 4794:); 4740:}; 4697:C# 4632:); 4608:]; 4590:-- 4578:() 4569:[[ 4481:, 4477:, 4444:); 4304:); 4268:10 4121:() 4070:++ 4058:() 3985:10 3970:); 3838:). 3826:10 3808:); 3790:() 3778:() 3656:11 3619:\n 3607:); 3604:10 3511:); 3505:)( 3414:\n 3402:); 3399:10 3282:); 3276:)( 3177:, 3173:, 3169:, 3167:C# 3165:, 3148:)) 3121:)) 2974:)) 2683::= 2641:^x 2626:. 2620:^x 2534:xs 2525:xs 2516:() 2498:) 2465:xs 2444:#( 2441::= 2438:xs 2381:, 2298::: 2202::: 2165:ML 2137:); 2134:id 2116:() 2086:of 2068:); 2004:); 1908:() 1893:42 1863:. 1856:. 1709:}; 1700:-- 1691:() 1679:}; 1670:++ 1661:() 1637:() 1581:. 1433:)) 1394:)) 1373:() 1316:)) 1307:(( 1295:#f 1280:#f 1246:. 1195:. 1184:dx 1167:dx 1161:)) 1143:dx 1110:dx 1057:); 945:)) 939:)) 825:. 801:, 795:ML 725:): 698:): 672:: 573:): 474:== 465:)( 444:== 435:)( 414:== 393:== 309:): 273:): 258:): 123:. 75:. 6236:. 6221:. 6205:. 6154:. 6127:. 6105:. 6087:. 6047:. 6029:. 6015:. 5990:. 5915:. 5889:. 5863:. 5747:: 5739:: 5717:. 5713:: 5707:6 5680:. 5666:: 5638:) 5634:( 5605:. 5534:* 5528:( 5496:* 5493:( 5442:y 5438:x 5422:) 5410:y 5407:, 5404:x 5401:( 5395:. 5386:) 5380:: 5377:y 5374:, 5371:x 5368:( 5362:( 5356:. 5350:. 5329:} 5317:} 5314:; 5311:y 5299:. 5296:s 5284:s 5278:{ 5275:) 5272:s 5260:( 5248:. 5245:n 5236:. 5233:n 5230:( 5218:= 5215:i 5206:; 5203:n 5188:; 5185:y 5179:{ 5176:) 5167:( 5109:} 5091:= 5070:= 5061:{ 5049:} 5043:; 5028:} 5025:; 5022:5 5019:+ 5016:a 5010:{ 4998:; 4992:= 4989:a 4983:{ 4971:} 4962:; 4959:3 4956:+ 4953:a 4947:{ 4935:; 4932:7 4929:= 4926:a 4920:{ 4904:D 4897:) 4891:* 4888:x 4885:) 4882:x 4879:( 4873:( 4867:. 4861:= 4852:2 4849:= 4840:} 4837:4 4834:, 4831:3 4828:, 4825:2 4822:, 4819:1 4816:{ 4813:= 4788:* 4785:x 4779:x 4776:( 4770:. 4764:= 4755:; 4752:2 4749:= 4737:4 4734:, 4731:3 4728:, 4725:2 4722:, 4719:1 4716:{ 4710:= 4683:f 4680:, 4674:( 4665:f 4662:, 4656:( 4647:f 4644:, 4638:( 4629:5 4626:( 4620:= 4617:f 4611:} 4602:] 4596:} 4593:; 4587:i 4581:{ 4572:^ 4563:; 4557:= 4554:i 4545:{ 4542:) 4533:( 4518:^ 4515:( 4498:^ 4475:C 4450:} 4441:) 4435:( 4429:. 4423:( 4417:. 4411:. 4399:. 4396:s 4390:s 4387:= 4375:, 4363:{ 4360:) 4351:( 4313:} 4310:} 4307:} 4301:i 4298:( 4292:. 4286:. 4280:{ 4277:) 4271:; 4256:. 4250:= 4247:i 4244:( 4235:. 4229:= 4226:i 4220:( 4205:. 4199:= 4190:. 4172:= 4163:{ 4160:) 4151:( 4136:} 4133:; 4124:{ 4109:} 4106:; 4103:0 4100:= 4094:{ 4091:; 4079:} 4076:} 4073:; 4061:{ 4046:{ 4031:{ 4003:} 4000:} 3988:; 3982:+ 3976:= 3964:( 3958:{ 3940:{ 3937:) 3925:( 3910:; 3895:{ 3850:} 3847:} 3835:} 3832:} 3829:; 3823:+ 3817:= 3802:( 3793:{ 3781:{ 3769:( 3757:{ 3754:) 3742:( 3727:; 3712:{ 3649:} 3646:; 3643:0 3634:1 3631:( 3625:, 3613:( 3601:( 3595:= 3586:} 3583:; 3574:} 3571:; 3565:+ 3556:{ 3553:) 3544:( 3535:{ 3532:) 3523:( 3499:* 3496:( 3487:{ 3484:) 3478:( 3444:} 3441:; 3438:0 3429:1 3426:( 3420:, 3408:( 3396:( 3390:= 3381:{ 3378:) 3372:( 3363:} 3357:; 3345:} 3342:; 3336:+ 3327:{ 3324:) 3315:( 3306:{ 3303:) 3294:( 3270:* 3267:( 3195:C 3171:D 3142:( 3136:( 3133:) 3127:( 3115:( 3109:( 3097:( 3091:) 3088:f 3085:( 3073:( 3070:) 3064:( 3058:( 3052:( 3049:) 3046:f 3043:( 3037:( 3034:) 3028:( 3022:( 3016:( 3013:) 3007:( 3001:( 2989:( 2983:) 2980:f 2977:( 2965:( 2962:) 2959:f 2956:( 2950:( 2947:) 2941:( 2935:( 2929:( 2926:) 2920:( 2914:( 2911:) 2899:( 2830:. 2827:f 2824:} 2815:{ 2809:= 2806:f 2779:. 2776:f 2773:} 2764:{ 2758:. 2752:= 2749:f 2695:f 2692:. 2680:f 2677:| 2674:f 2671:| 2665:^ 2604:^ 2588:( 2582:} 2579:; 2576:0 2567:; 2564:x 2558:{ 2555:) 2552:x 2549:( 2543:( 2537:. 2531:; 2528:= 2519:{ 2488:( 2477:0 2474:^ 2471:. 2462:. 2459:) 2456:4 2453:3 2450:2 2447:1 2435:| 2429:| 2415:^ 2359:r 2352:) 2346:f 2343:( 2337:= 2331:0 2328:1 2322:= 2319:f 2316:a 2310:a 2304:a 2295:f 2292:y 2289:/ 2286:x 2283:= 2280:r 2274:) 2271:r 2268:+ 2265:z 2259:z 2256:\ 2253:( 2250:= 2247:y 2244:x 2238:) 2235:a 2229:a 2226:( 2220:a 2214:a 2208:a 2150:e 2143:} 2140:} 2131:. 2128:e 2125:( 2119:{ 2107:= 2101:. 2098:e 2095:{ 2092:) 2083:e 2077:( 2062:( 2056:. 2050:= 2019:( 2013:. 1998:( 1992:. 1986:= 1965:( 1959:. 1953:; 1947:. 1941:= 1932:} 1929:} 1926:; 1923:x 1920:. 1911:{ 1902:: 1896:, 1890:: 1887:x 1884:{ 1881:= 1854:x 1850:g 1846:f 1829:f 1826:+ 1820:( 1808:f 1805:+ 1799:( 1787:g 1784:+ 1778:( 1766:g 1763:+ 1757:( 1742:} 1736:f 1733:+ 1727:( 1721:; 1718:1 1715:= 1712:x 1706:; 1703:x 1694:{ 1685:= 1682:g 1676:; 1673:x 1664:{ 1655:= 1652:f 1649:; 1646:x 1640:{ 1628:; 1625:g 1622:, 1619:f 1511:D 1427:( 1421:( 1418:) 1409:( 1406:) 1400:( 1388:( 1382:( 1367:( 1358:( 1343:( 1340:) 1334:( 1328:( 1319:( 1301:( 1298:) 1286:( 1283:) 1271:( 1180:f 1173:} 1170:; 1164:/ 1158:x 1155:( 1152:f 1149:- 1146:) 1140:+ 1137:x 1134:( 1131:f 1128:( 1122:x 1116:{ 1113:) 1107:, 1104:f 1101:( 1060:} 1045:. 1033:( 1027:. 1018:{ 1015:) 1009:( 933:) 924:( 918:( 915:) 909:( 903:( 897:( 894:) 885:( 879:( 764:) 761:1 758:( 755:g 752:) 749:z 746:( 743:f 734:1 731:= 728:x 722:z 719:( 716:g 710:y 707:+ 704:x 695:y 692:( 689:f 683:0 680:= 677:x 670:g 666:x 662:x 658:f 654:x 650:f 636:) 630:, 627:y 624:+ 621:x 618:: 615:y 609:( 603:) 597:, 594:f 591:( 585:y 582:+ 579:x 570:y 567:( 564:f 558:= 552:1 549:= 546:x 539:x 535:x 531:x 511:g 507:b 503:a 499:x 491:b 487:a 477:6 471:) 468:5 462:1 459:( 456:h 447:6 441:) 438:5 432:1 429:( 426:f 417:6 411:) 408:5 405:( 402:b 396:6 390:) 387:5 384:( 381:a 372:) 369:1 366:( 363:h 360:= 357:b 354:) 351:1 348:( 345:f 342:= 339:a 330:y 327:+ 324:x 321:: 318:y 306:x 303:( 300:h 291:g 285:y 282:+ 279:x 270:y 267:( 264:g 255:x 252:( 249:f 45:. 38:. 20:)

Index

Closure (computer science)
Closure (mathematics)
Closure (disambiguation)
Clojure
programming languages
lexically scoped
name binding
first-class functions
Operationally
record
function
free variable
value
reference
λ-calculus
PAL programming language
first-class functions
Peter Landin
SECD machine
Joel Moses
lambda expression
Sussman
Steele
Scheme
Lisp
Abelson
data structure
mathematics use
Anonymous function
anonymous function

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑