December 2021
Beginner
840 pages
47h 29m
English
An understanding of lexical closures is fundamental not only to this chapter, but more broadly to the study of programming languages. A closure is a function that remembers the lexical environment in which it was created. A closure can be thought of as a pair of pointers: one to a block of code (defining the function) and one to an environment (in which function was created). The bindings in the environment are used to evaluate the expressions in the code. Thus, a closure encapsulates data and operations and thus, bears a resemblance to an object as used in object-oriented programming. Closures are powerful constructs in functional programming (as we see throughout this text), and an essential element ...
Read now
Unlock full access