Lably
Skip to content

Closure (computer programming)

Technique for creating lexically scoped first class functions

  • 47 min read
  • 6 chapters

Related on Lably

Through Scope (computer programming), Record (computer science) and Function (computer programming)

History and etymology

The concept of closures was developed in the 1960s for the mechanical evaluation of expressions in the λ-calculus and was first fully implemented in 1970 as a language feature in the PAL programming language to support lexically scoped first-class functions.

Peter Landin defined the term closure in 1964 as having an environment part and a control part as used by his SECD machine for evaluating expressions. Joel Moses credits Landin with introducing the term closure to refer to a lambda expression with open bindings (free variables) that have been closed by (or bound in) the lexical environment, resulting in a closed expression, or closure. This use was subsequently adopted by Sussman and Steele when they defined Scheme in 1975, a lexically scoped variant of Lisp, and became widespread.

Sussman and Abelson also use the term closure in the 1980s with a second, unrelated meaning: the property of an operator that adds data to a data structure to also be able to add nested data structures. This use of the term comes from mathematics use, rather than the prior use in computer science. The authors consider this overlap in terminology to be "unfortunate."

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Computing and communication