12.5 Lazy Evaluation
At its core, lazy evaluation is a parameter-passing strategy in which an operand is evaluated only when its value is needed. This simple idea has compelling consequences. An obvious advantage of this approach is that if the value of an operand is never needed in the body of a function, then the time required to evaluate it is saved. Most languages, including Python and Java, implement short-circuit evaluation, which is an instance of lazy evaluation restricted to boolean operators. For instance, in the expression false && (true || false), there is no need to evaluate the subexpression on the right-hand side of the logical “and” (&&) operator.
In what follows, we first describe the mechanics of the lazy ...