Log in / create account | Login with OpenID
DocForge
Programmer's Wiki

Lazy evaluation

From DocForge

Lazy evaluation refers to a feature of programming languages where expressions are not evaluated until they are actually used by the program. This allows such tricks as casually generating and using infinite sequences without running out of memory, since only a portion of the sequence is generated or evaluated at any given time. (Note that this can be of course be done in eager languages as well, but essentially requires implementing lazy evaluation by hand and a certain degree of caution.)

The canonical "lazy" language is Haskell, though other languages such as Lisp and Python support the explicit use of it in programs. The alternative to lazy evaluation is eager evaluation, which is generally the default in existing programming languages.

Do you have information or insights to contribute to this article? Please feel free to edit this page. Ask questions or contribute to the discussion on this article's talk page.