Hello,
R7RS draft 9 has the following example:
> 1: (define count 0)
> 2: (define p
> 3: (delay (begin (set! count (+ count 1))
> 4: (if (> count x)
> 5: count
> 6: (force p)))))
> 7: (define x 5)
> 8: p
> 9: (force p)
force has the following description:
> If no value has been computed for the promise,
> then a value is computed and returned. The value
> of the promise must be cached (or "memoized") so
> that if it is forced a second time, the previously
> computed value is returned.
Arguably, the "first time" the promise is forced is at line 9 in the
example, and the "second time" is at line 6. However, at that time
line 6 gets executed, no value has been computed *yet*, so presumably
this example follows the spirit of the law.
However, this example, I think, limits implementation options.
1. The G-Machine technique for laziness, which black-holes unforced
promises at time of forcing, cannot be used, because it would have to
raise a "black hole encountered!" exception at line 6.
2. We have to be more careful of implementing promises in a
multithreaded environment.
_______________________________________________ Scheme-reports mailing list Scheme-reports@x http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports