From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: doco delay Date: Tue, 03 Jun 2003 10:02:07 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <877k84f2ps.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1054599953 29107 80.91.224.249 (3 Jun 2003 00:25:53 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 3 Jun 2003 00:25:53 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jun 03 02:25:52 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Mzcd-0007ZL-00 for ; Tue, 03 Jun 2003 02:25:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19MzcM-0006tS-22 for guile-devel@m.gmane.org; Mon, 02 Jun 2003 20:25:34 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19MzaN-0006Tl-5r for guile-devel@gnu.org; Mon, 02 Jun 2003 20:23:31 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19MzKa-0003O1-Ua for guile-devel@gnu.org; Mon, 02 Jun 2003 20:07:17 -0400 Original-Received: from snoopy.pacific.net.au ([61.8.0.36]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19MzG0-0002fq-2V for guile-devel@gnu.org; Mon, 02 Jun 2003 20:02:28 -0400 Original-Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) h5302QPB031475 for ; Tue, 3 Jun 2003 10:02:26 +1000 Original-Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h5302PQg015038 for ; Tue, 3 Jun 2003 10:02:25 +1000 (EST) Original-Received: from localhost (ppp92.dyn228.pacific.net.au [203.143.228.92]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h5302MYZ014317 for ; Tue, 3 Jun 2003 10:02:23 +1000 (EST) Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19MzFg-0002Qj-00; Tue, 03 Jun 2003 10:02:08 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2482 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2482 --=-=-= 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. --=-=-= Content-Disposition: attachment; filename=scheme-evaluation.texi.delay.diff --- 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 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--