lazy evaluation


Also found in: Wikipedia.

lazy evaluation

[′lā·zē i‚val·yə′wā·shən]
(computer science)

lazy evaluation

(reduction)
An evaluation strategy combining normal order evaluation with updating. Under normal order evaluation (outermost or call-by-name evaluation) an expression is evaluated only when its value is needed in order for the program to return (the next part of) its result. Updating means that if an expression's value is needed more than once (i.e. it is shared), the result of the first evaluation is remembered and subsequent requests for it will return the remembered value immediately without further evaluation. This is often implemented by graph reduction. An unevaluated expression is represented as a closure - a data structure containing all the information required to evaluate the expression.

Lazy evaluation is one evaluation strategy used to implement non-strict functions. Function arguments may be infinite data structures (especially lists) of values, the components of which are evaluated as needed.

According to Phil Wadler the term was invented by Jim Morris.

Opposite: eager evaluation.

A partial kind of lazy evaluation implements lazy data structures or especially lazy lists where function arguments are passed evaluated but the arguments of data constructors are not evaluated.

Full laziness is a program transformation which aims to optimise lazy evaluation by ensuring that all subexpressions in a function body which do not depend on the function's arguments are only evaluated once.
References in periodicals archive ?
The bizarre, surreal management mess at NUFC even appears to be metamorphosing into an easy, lazy evaluation of Newcastle's ability to manage itself in the eyes of a few tunnel-visioned businesspeople I spoke to.
The language also supports recursive functions and datatypes, as well as lazy evaluation.
The aim of lazy evaluation [Friedman and Wise 1976; Henderson and Morris 1976], which underlies lazy functional languages (e.
In order to reduce this kind of overhead, in practice lazy evaluation is often adapted to do a lot of eager evaluation.
We investigate how an eager implementation can be adapted to do some lazy evaluation.
A standard application of lazy evaluation, where compared to eager evaluation it improves both termination behavior and performance, is the if-then-else construct:
In order to solve this inefficiency, lazy evaluation is usually performed by graph rewriting [Staples 1980] instead of term rewriting.
Two implementations are possible: a full evaluation scheme computes the entire set of answers at once, while a lazy evaluation scheme computes only the result, and nodes from inner operands of the query syntax tree are obtained only if they are necessary to compute the final result.
Experimental results (as demonstrated later) show that lazy evaluation is normally better.
For lazy evaluation, instead, we keep a pointer to a node in the disk, and ask it to do the following (3) given a node, retrieve all of its top-level descendants of the same type and (4) given a node, retrieve all of its children.
Observe that this index is not well suited for lazy evaluation, since it cannot efficiently implement (3).
With three words per node, a version of the partial index suitable for lazy evaluation can be designed.