[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strict promises?
On Sat, 31 Jan 2004 campbell@xxxxxxxxxxxxxxxxxx wrote:
> I just found myself wanting to create a promise, but not to delay its
> evaluation. I could do
> (let ((p (delay <expression>)))
> (force p)
> but that would needlessly compute and complicate. STRICT would do just
> what I want. Why was STRICT not provided in the first place, in fact?
OK, I'm convinced now that it is a good thing to add STRICT for this
need, which is actually quite common. I would like to change its name,
though. Since it has the same type signature as delay, I propose to use
the verb RELAY (= passing along something, in this case a value wrapped in
a promise). So we have
delay : a -> Promise a : wraps its unevaluated argument in a promise
relay : a -> Promise a : wraps its evaluated argument in a promise
The semantics is observationally equivalent to
(relay exp) = (let ((x exp)) (delay exp))
but it admits a more efficient implementation (no superfluous thunk
creation and evaluation).
Unless there are strong objections, I will include this in the document as
soon as I have time.