[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

doco delay

From: Kevin Ryde
Subject: doco delay
Date: Tue, 03 Jun 2003 10:02:07 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

Getting delay described, for completeness.

        * scheme-evaluation.texi (Delayed Evaluation): Add delay, reword
        promise? and force a bit, describe recursive forcing of a promise by
        its own code.

I'm assuming the R5RS sample code for promises is to be read as a
specification for what should happen in a recursive force.  It's the
way guile works at least.

Delayed Evaluation

Promises are a convenient way to defer a calculation until its result
is actually needed, and to run such a calculation only once.

 - syntax: delay expr
     Return a promise object which holds the given EXPR expression,
     ready to be evaluated by a later `force'.

 - Scheme Procedure: promise? obj
 - C Function: scm_promise_p (obj)
     Return true if OBJ is a promise.

 - Scheme Procedure: force p
 - C Function: scm_force (prom)
     Return the value obtained from evaluating the EXPR in the given
     promise P.  If P has previously been forced then its EXPR is not
     evaluated again, instead the value obtained at that time is simply

     During a `force', an EXPR can call `force' on its own promise,
     resulting in a further recursive evaluation of that EXPR.  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, `force' always returns the first value.

Attachment: scheme-evaluation.texi.delay.diff
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]