--- scheme-evaluation.texi.~1.9.~ 2002-09-25 10:06:38.000000000 +1000 +++ scheme-evaluation.texi 2003-06-03 09:58:31.000000000 +1000 @@ -319,20 +319,36 @@ @node Delayed Evaluation @section Delayed Evaluation address@hidden delayed evaluation address@hidden promises -[delay] +Promises are a convenient way to defer a calculation until its result +is actually needed, and to run such a calculation only once. + address@hidden syntax delay expr address@hidden delay +Return a promise object which holds the given @var{expr} expression, +ready to be evaluated by a later @code{force}. address@hidden deffn @deffn {Scheme Procedure} promise? obj @deffnx {C Function} scm_promise_p (obj) -Return true if @var{obj} is a promise, i.e. a delayed computation -(@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). +Return true if @var{obj} is a promise. @end deffn @rnindex force address@hidden {Scheme Procedure} force x address@hidden {C Function} scm_force (x) -If the promise @var{x} has not been computed yet, compute and -return @var{x}, otherwise just return the previously computed address@hidden {Scheme Procedure} force p address@hidden {C Function} scm_force (prom) +Return the value obtained from evaluating the @var{expr} in the given +promise @var{p}. If @var{p} has previously been forced then its address@hidden is not evaluated again, instead the value obtained at that +time is simply returned. + +During a @code{force}, an @var{expr} can call @code{force} on its own +promise, resulting in a further recursive evaluation of that address@hidden The first evaluation to return gives the value for the +promise. Higher evaluations run to completion in the normal way, but +their results are ignored, @code{force} always returns the first value. @end deffn