[R6RS] Convenient syntax for multiple values

dyb at cs.indiana.edu dyb
Fri Dec 10 12:44:01 EST 2004


> That's also reasonable, but LET-VALUES seems more in the spirit of
> extending R5RS.

I prefer let-values as well and don't see a problem with implementing
it efficiently.

In Chez Scheme / Petite Chez Scheme,

(let-values ([(a b c) (foo bar)] [(d e) (baz)]) (list a b c d e))

expands into

(call-with-values
  (lambda () (foo bar))
  (lambda (t0 t1 t2)
    (call-with-values
      (lambda () (baz))
      (lambda (t3 t4)
        ((lambda (d e a b c) (list a b c d e))
         t3 t4 t0 t1 t2)))))

Since the variables are unassigned in this case, this reduces to

(call-with-values
  (lambda () (foo bar))
  (lambda (t0 t1 t2)
    (call-with-values
      (lambda () (baz))
      (lambda (t3 t4)
        (list t0 t1 t2 t3 t4)))))

after copy propagation.

Kent


More information about the R6RS mailing list