Am Sa., 3. Sept. 2022 um 19:21 Uhr schrieb John Cowan <[email protected]>: > > > > 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))
That would work if all procedures returned by "lambda" and by all other procedure constructors but "force" and "make-promise" and using only the standard exports of R7RS to construct them are guaranteed to be disjoint from possible values on which "promise?" returns true. I may be wrong but I currently don't see where R7RS makes this guarantee.
