On Sat, Sep 3, 2022 at 12:45 PM Marc Nieper-Wißkirchen <
[email protected]> wrote:

> Am Sa., 3. Sept. 2022 um 15:51 Uhr schrieb Wolfgang Corcoran-Mathe
> <[email protected]>:
>


> > 9. Major suggestion: Would it be reasonable for all of the
> > syntax-like procedures to accept thunks *or* promises?  I believe
> > this could be very useful, although the names might need tweaking.
> >
> > Delayed evaluation always gets short shrift in Scheme.  It would
> > be a sad statement of the current situation for something called
> > "lazy-and-procedure" to have nothing to do with delayed evaluation.
>

Thunks are a form of delayed evaluation that do
 not memoize, unlike promises.

> Promises do not form a disjoint type. Runtime-dispatch won't be
> possible. Or what do you have in mind?
>

That's all right, as long as you test 'promise?' before 'procedure?', thus:

(cond ((promise? thunk)
           (force thunk))
          ((procedure? thunk)
           (thunk))
          (t (error "not a thunk")))

or more simply:

((promise? thunk) (force thunk) (thunk))

Reply via email to