manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.17.9 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. Also see section SRFI-45 - Primitives for Expressing Iterative Lazy Algorithms.

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 (p)

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 again on its own promise, resulting in a 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.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.