[racket] Multiple return values

From: Stephan Houben (stephanh at planet.nl)
Date: Thu Dec 15 08:15:01 EST 2011

On 12/15/2011 12:39 PM, Zayr Okale wrote:
>
> Unfortunately, this scenario doesn't apply to Racket. And this is exactly what prompted my question. Since one of the reasons behind multiple return values is, as David Van
> Horn pointed out, symmetry with multiple input values (function arguments), then why optional input values are allowed, but optional output values aren't?

But they are supported!

(define-syntax first-value-only
   (syntax-rules ()
     ((_ e)
      (call-with-values (λ () e)
                        (λ (x . rest) x)))))

(printf "~a~%" (first-value-only (values 1 2 3)))

In fact, just like optional input values, they are supported but not the default.

Stephan


Posted on the users mailing list.