Lazy Evaluation
Updated 2026-07-28
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.
Introduction
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/1Practice this model in one real situation:
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.
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E6%83%B0%E6%80%A7%E6%B1%82%E5%80%BCverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS