Lazy Evaluation

In programming language theory, lazy evaluation or call-by-need is an evaluation strategy which delays the evaluation of an expression until its value is needed (non-strict evaluation) and which also avoids repeated evaluations (sharing). The sharing can reduce the running time of certain functions by an exponential factor over other non-strict evaluation strategies, such as call-by-name.

The benefits of lazy evaluation include:

  • Performance increases by avoiding needless calculations, and error conditions in evaluating compound expressions
  • The ability to construct potentially infinite data structures
  • The ability to define control flow (structures) as abstractions instead of primitives

Lazy evaluation can lead to reduction in memory footprint, since values are created when needed. However, with lazy evaluation, it is difficult to combine with imperative features such as exception handling and input/output, because the order of operations becomes indeterminate. Lazy evaluation can introduce space leaks.

The opposite of lazy actions is eager evaluation, sometimes known as strict evaluation. Eager evaluation is commonly the default behavior used in programming languages.

Read more about Lazy Evaluation:  History, Applications, Laziness in Eager Languages, Controlling Eagerness in Lazy Languages

Famous quotes containing the words lazy and/or evaluation:

    Take us generally as a people, we are neither lazy nor idle; and considering how little we have to excite or stimulate us, I am almost astonished that there are so many industrious and ambitious ones to be found; although I acknowledge, with extreme sorrow, that there are some who never were and never will be serviceable to society. And have you not a similar class among yourselves?
    Maria Stewart (1803–1879)

    Good critical writing is measured by the perception and evaluation of the subject; bad critical writing by the necessity of maintaining the professional standing of the critic.
    Raymond Chandler (1888–1959)