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

Re: strict promises?

This page is part of the web mail archives of SRFI 45 from before July 7th, 2015. The new archives for SRFI 45 contain all messages, not just those from before July 7th, 2015.

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)
>     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.