Chapter 12

Lazy Evaluation

By using functions as values, it becomes possible to replace data with a function that computes this data. With this approach, the evaluation of arguments can be delayed until they are needed, making it possible to pass unevaluated code to methods and functions. Combined with syntactic help from the language, it becomes possible to define additional control structures from within a programming language, leading potentially to the definition of an internal domain-specific language. Functions can also be stored within data structures to delay the evaluation of parts of that structure. Streams are a classic functional programming structure that implements lazily evaluated sequences. Besides unevaluated arguments and ...

Get Functional and Concurrent Programming: Core Concepts and Features now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.