[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Questions about writing a C library
- From: Phil Bewig <pbewig@...>
- Date: Wed, 24 Mar 2004 18:14:11 +0000 (UTC)
<RLake <at> oxfam.org.pe> writes:
> >> In a parallel universe far from here, I am
> >> currently finalizing srfi-40 for streams; would an
> >> explicit delay/force, as in scheme, fit the language?
> > How does this differ from nullary closures?
> I think the difference is that delay/force tries to
> guarantee that the computation only happens once. This
> can be done with a nullary closure, but it requires some
> machinery.
This is correct. The semantics of scheme require that a delayed
computation be performed exactly once, when it is forced, and that
the result be cached so if the computation is forced a second time
the precomputed result is returned without additional computation.
See the definition of delay in R5RS section 4.2.5 and the definition
of force in R5RS section 6.4.
Phil