Chapter 6
Encapsulating Data in Closures
WHAT’S IN THIS CHAPTER?
- Constructing functions dynamically
- Solving scope issues with closures
The capability of a programming language to work with higher order functions means that the problem of data scope becomes apparent. When functions are passed around as parameters and return values, the compiler uses closures to extend variable scope so that data is guaranteed to be available when needed.