lua-users home
lua-l archive

Re: Questions about writing a C library

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


<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

AltStyle によって変換されたページ (->オリジナル) /