iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Call by name is an evaluation strategy that passes a function an unevaluated expression and evaluates it only when the function uses its parameter. If the parameter is never used, the expression may never run. If it is used repeatedly, the expression may be evaluated repeatedly.
How call by name works
With call by name, a function begins executing before its argument has been reduced to a value. When the function needs the corresponding parameter, the argument expression is evaluated in the caller’s environment. In formal lambda calculus, this is often described as substituting the unevaluated expression into the function body, while avoiding variable capture. The University of Colorado Boulder’s course text explains the delayed evaluation rule, and Programming Language Foundations in Agda presents call by name as a deterministic evaluation strategy for lambda-calculus terms.
For example, consider a function that always returns 1 and never refers to its parameter. Under call by name, an argument expression that would fail if evaluated does not need to run, because the function never demands it. The same principle supports short-circuit behavior: Magma’s handbook gives the example false and (4/0 eq 6), which yields false without evaluating the division by zero. Magma documents this behavior for the relevant operator.
Call by name vs. call by value vs. call by need
The main difference is when the argument starts running and whether its result is reused.
#1 Best Overall
| Strategy | When argument evaluation begins | What happens when the parameter is used repeatedly | Practical tradeoff |
|---|---|---|---|
| Call by value | Before the function body begins | The computed value is reused | May perform work for an argument the function never uses. |
| Call by name | When the function first needs the parameter | The expression may be evaluated again for each use | Can avoid unnecessary work, but may duplicate computation. |
| Call by need | When the function first needs the parameter | The first result is stored and reused | Delays work while sharing its result. |
Call by need is therefore not just another name for call by name: both delay evaluation, but call by need adds sharing, often called memoization. Aalto University’s glossary describes this distinction and names Haskell as an example of call-by-need; its examples also identify Scala by-name parameters.
Why repeated uses matter
Suppose a function refers to its parameter three times and the argument performs an expensive calculation. With call by name, each reference can trigger another evaluation of that calculation. With call by need, the first evaluation’s result is reused. Whether this makes a program slower depends on the work involved, how many times the parameter is used, and the implementation; there is no fixed performance penalty. The OCaml tutorial and Harvey Mudd College course notes discuss the cost of repeated evaluation.
Rank #2
Call by name is not the same as normal order
These terms are related but not interchangeable. In lambda calculus, call by name reduces a function application without first evaluating its argument. The exact description depends on the evaluation relation being used. Notre Dame’s course notes distinguish call by name from normal order: call by name does not reduce inside lambda abstractions and stops when it reaches a value, whereas normal order can continue reducing inside abstractions.
How to recognize it in a language
Do not infer a language’s evaluation strategy just from source code that looks lazy. A language may use different rules for ordinary function arguments, operators, or specially annotated parameters. For instance, Aalto’s glossary discusses Scala by-name parameters, while Magma’s handbook documents call-by-name behavior for selected operators. For a particular construct, check the documentation for that language and version rather than assuming every expression follows one rule.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

