Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: Further Reading, Previous: About Expressions, Up: Hello Scheme! [Contents][Index]
The concept of closure is the idea that a lambda expression “captures” the variable bindings that are in lexical scope at the point where the lambda expression occurs. The procedure created by the lambda expression can refer to and mutate the captured bindings, and the values of those bindings persist between procedure calls.
This section explains and explores the various parts of this idea in more detail.
• About Environments: | Names, locations, values and environments. | |
• Local Variables: | Local variables and local environments. | |
• Chaining: | Environment chaining. | |
• Lexical Scope: | The meaning of lexical scoping. | |
• Closure: | Explaining the concept of closure. | |
• Serial Number: | Example 1: a serial number generator. | |
• Shared Variable: | Example 2: a shared persistent variable. | |
• Callback Closure: | Example 3: the callback closure problem. | |
• OO Closure: | Example 4: object orientation. |