Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M4558

Lazy Evaluation

Lazy Evaluation
Learn & MetacognitionHigh supportCognitive Science
Included
account_tree

Updated 2026-07-28

Loading revision record…

Summary

In programming language theory, lazy evaluation, also translated as delayed evaluation or lazy computation, and also known as call-by-need, is a concept in computer programming aimed at minimizing the work the computer has to do. The most important benefit of lazy evaluation is that it can greatly optimize space complexity, thus making it easy to construct infinite data types. The opposite of lazy evaluation is eager evaluation, which is the default computation method used by most programming languages, such as C.

Definition

In programming language theory, lazy evaluation, also translated as delayed evaluation or lazy computation, and also known as call-by-need, is a concept in computer programming aimed at minimizing the work the computer has to do. The most important benefit of lazy evaluation is that it can greatly optimize space complexity, thus making it easy to construct infinite data types. The opposite of lazy evaluation is eager evaluation, which is the default computation method used by most programming languages, such as C. Due to translation issues, this term has two related but distinct meanings in different contexts, which can be expressed as 'delayed evaluation' and 'minimized evaluation'. The main content of this entry is about delayed evaluation; for the latter, please refer to the entry on minimal computation.

How to use

In programming language theory, lazy evaluation, also translated as delayed evaluation or lazy computation, and also known as call-by-need, is a concept in computer programming aimed at minimizing the work the computer has to do. The most important benefit of lazy evaluation is that it can greatly optimize space complexity, thus making it easy to construct infinite data types. The opposite of lazy evaluation is eager evaluation, which is the default computation method used by most programming languages, such as C.

Mechanism

Expressions are not evaluated at binding time, but only when first needed, and the result can be cached and reused. The mechanism is to postpone computation until necessary, avoiding useless work.

Practice

In progress 0/1

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

Cases

  • Haskell is lazy by default; Python generators produce on demand.

Common pitfalls

  • Space leaks (keeping large unevaluated structures); or mistakenly assuming it is always faster.
Sources

Source support: Explicit

References currently contain only Wikipedia links; primary sources still need review.

  • link
    zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E6%83%B0%E6%80%A7%E6%B1%82%E5%80%BCZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS