On Jul 20, Alan Watson wrote:
> The text associated with delay and force in the R5.97RS (and the R5RS,
> for that matter) talks about "a value" rather than "values".
> Nevertheless, I see no reason why force should not deliver multiple
> values to its continuation. In the context of the example implementation
> given in R5.97RS, I would suggest the following definition of make-promise:
>
> (define make-promise
> (lambda (proc)
> (let ((results #f))
> (lambda ()
> (apply values
> (or results
> (let ((x (call-with-values proc list)))
> (if (not results)
> (set! results x))
> results)))))))
An even better fix is to get rid of the closure:
(define make-promise
(lambda (x)
(lambda ()
(apply values
(if (list? x)
x
(let ((r (call-with-values proc list)))
(if (not results)
(set! x r))
r))))))
but see srfi-45. (Which was suggested, and probably fell between the
cracks.)
> With this, the following:
>
> (call-with-values (lambda () (force (delay (values 0 1 2)))) list)
>
> gives (0 1 2) rather than (0).
>
> Regards,
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!
Received on Fri Jul 20 2007 - 13:06:11 UTC