University of Washington • CSE583 • D. Notkin © 2000
57
Closures
lThe solution for static scoping is to return functions as a closure
lA closure defines the code for the function and its environment
–Environment records bindings of free variables
–Closure is no longer dependent on the enclosing scope
–The closure is heap-allocated
–Languages with closures include Scheme, ML, Haskell, Smalltalk-80, Cecil
–