Jump to content

Delay (programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 2ndMouse (talk | contribs) at 15:59, 24 March 2007 (Created page with 'In computer science, '''Delayed evaluation''' is used in some programming languages to delay the evaluation on an expression until its value is needed. ==Defin...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In computer science, Delayed evaluation is used in some programming languages to delay the evaluation on an expression until its value is needed.

Definition

The denotational semantics of programming languages can be used to provide a definition of futures: An expression of the form delay <Expression> is defined by how it responds to an Eval message with environment E and customer C as follows: The delay expression sends C a newly created actor D which is a proxy for the value of the expression <Expression> that has a body <Expression> and an environment E that behaves as follows:


  • When D receives a request R, then it checks to see if it has already received a return value from evaluating <Expression> proceeding as follows:
  1. If it already has a return value V, then V is sent the request R.
  2. If it does not already have a return value then it sends <Expression> an Eval message and stores the returned value in itself, then the returned value is sent the request.


References

  • Daniel Friedman and David Wise. "Cons should not evaluate its arguments."

S. Michaelson and R. Milner, editors, Automata, Languages and Programming, Edinburgh University Press, Edinburgh. 1976