unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* doco delay
@ 2003-06-03  0:02 Kevin Ryde
  2003-06-04 16:32 ` Kevin Ryde
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Ryde @ 2003-06-03  0:02 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1425 bytes --]

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
     returned.

     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 #2: scheme-evaluation.texi.delay.diff --]
[-- Type: text/plain, Size: 1739 bytes --]

--- 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
+@cindex delayed evaluation
+@cindex 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.
+
+@deffn syntax delay expr
+@rnindex delay
+Return a promise object which holds the given @var{expr} expression,
+ready to be evaluated by a later @code{force}.
+@end 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
-@deffn {Scheme Procedure} force x
-@deffnx {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
+@deffn {Scheme Procedure} force p
+@deffnx {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
+@var{expr} 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
+@var{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, @code{force} always returns the first
 value.
 @end deffn
 

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: doco delay
  2003-06-03  0:02 doco delay Kevin Ryde
@ 2003-06-04 16:32 ` Kevin Ryde
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Ryde @ 2003-06-04 16:32 UTC (permalink / raw)


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

In absense of violent objections I applied this change.


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-06-04 16:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-03  0:02 doco delay Kevin Ryde
2003-06-04 16:32 ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).