Talk:Closure (computer programming)/to do


 * Introduction
 * Rewrite lead paragraph (mostly done)
 * In such languages a reference to a function is a reference to a closure...
 * Closure = Function + Environment
 * What happens when creating a closure? (Closure captures the current lexical environment)
 * What happens when entering a closure? (Function is executed in the lexical environment captured by the closure)
 * Picture?
 * Mention all relevant terminology: open, closed, free, bound, captured, closed over
 * Mention closures are an implementation technique for supporting first-class functions
 * Theory: closures in operational semantics
 * Add an introductory section
 * Targeted primarily at imperative programmers who have little experience with non-local variables
 * Closures are an implementation technique
 * A form of activation record on the heap
 * Compare with a stack-allocated version of activation records for nested functions
 * History
 * Early languages:
 * POP-2, POP-11; POP-11: a practical language for artificial intelligence
 * PAL; 1968, 1970; http://www.softwarepreservation.org/projects/lang/PAL
 * Scheme; 1975
 * Semantics
 * Closure (computer programming): Scheme (variables in scope) vs. Smalltalk (variables + return + self) vs, Java 7/8/... (variables + return + this + exceptions + ...)
 * Capturing loop variables
 * Capture by reference vs. capture by copy, extending the lifetime and garbage collection (compare C++)
 * Implementation
 * Luca Cardelli, Compiling a Functional Language.
 * Simon Peyton Jones, Implementation of Functional Programming Languages.
 * Z. Shao and A. W. Appel. Space-efficient closure representations.
 * Upvalues: Roberto Ierusalimschy et al., "The Implementation of Lua 5.0"
 * Funarg problems: closures are intended to solve the more difficult upwards funarg problem, but sometimes also used to solve the downwards.
 * Applications: thunk (delayed computation), memoization, object system, hidden state/static variables
 * Closure (computer programming): This can be used in lazy pure languages as well, e.g. storing a memoization table in the closure which is lazyily evaluated when needed but not discarded.