[r6rs-discuss] Promises and Multiple Values
Alan Watson
alan at alan-watson.org
Fri Jul 20 12:32:25 EDT 2007
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)))))))
With this, the following:
(call-with-values (lambda () (force (delay (values 0 1 2)))) list)
gives (0 1 2) rather than (0).
Regards,
Alan
More information about the r6rs-discuss
mailing list