Linux Today: Linux News On Internet Time.

developerWorks: Lazy Programming and Lazy Evaluation

Dec 21, 2006, 05:30 (0 Talkback[s])
(Other stories by Jonathan Bartlett)

[ Thanks to An Anonymous Reader for this link. ]

"Lazy programming is a technique that lets you delay the evaluation of code until you need the resulting value. In Scheme, for example, lazy programming is explicitly supported through two special constructs. Scheme's delay special form takes a block of code and, rather than executing it, stores the code and its parameters as a promise. If you force the promise to produce a value, it will then run the code. The promise then saves the result, so that future requests for the value will be returned instantly without having to execute the code again.

"Here is a simple example of how delay and force work together..."

Complete Story

Related Stories: