GNU Info

Info Node: (guile.info)About Closure

(guile.info)About Closure


Prev: About Expressions Up: Basic Ideas
Enter node , (file) or (file)node

The Concept of Closure
======================

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.

automatically generated by info2www version 1.2.2.9