[racket] Named let and multiple values

From: Justin Zamora (justin at zamora.com)
Date: Thu Jul 28 00:28:28 EDT 2011

I'd like to be able to write something like this:

(let loop ([a 1] [b 2])
   (if (= a b)
      (loop (values (add1 a) b))))

This would match the way for/fold works with more than one value.
However, I get a message, "context expected 1 value, received 2
values: 2 2", which makes sense given the expansion of named let, but
it would be nice if this worked.  Using (call-with-values (lambda ()
(values (add1 a) b)) loop) works, but that seems to defeat the point
of using a named-let form for clarity.  I could also use let-values to
deconstruct the values and pass them individually to the loop, but
that hardly seems better.  Is there a better way?


Posted on the users mailing list.