[r6rs-discuss] Promises and Multiple Values

From: Alan Watson <alan>
Date: Fri, 20 Jul 2007 11:32:25 -0500

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
Received on Fri Jul 20 2007 - 12:32:25 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC