Jump to content

Talk:Closure (computer programming)/to do

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
  • 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
  • Semantics
    • Closure (computer programming)#Differences in semantics: 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

Start a discussion