Learning path

Full curriculum

Full curriculum

Unit content

Evaluation strategies

A language must decide which reducible expression to evaluate next. Different evaluation strategies can produce the same result when all computations terminate, yet differ sharply in termination, side effects and cost.

In call by value, an argument is evaluated to a value before it is substituted into a function body. Thus

$$(\lambda x.1)\ \Omega$$

tries to evaluate $\Omega$ first and diverges.

In call by name, the unevaluated argument is substituted directly. The same expression reduces immediately to $1$ because the body never uses $x$.

Call by need, or lazy evaluation, has the demand behavior of call by name but remembers the result of an argument the first time it is evaluated, avoiding repeated work.

These strategies matter once expressions can diverge or perform effects. With pure terminating expressions they may be observationally indistinguishable; with mutation or I/O, changing evaluation order can change visible behavior.

An evaluation strategy is therefore part of a language's semantics, not merely an optimization. It determines when computations happen and which computations happen at all.