[plt-scheme] Multiple values
hufflen jean-michel wrote:
> Dear PLT Scheme friends,
>
> I have a "philosophical" question. If I write:
>
> (+ 0 (values 1 2))
>
> that causes an error, because "+" can consume only one value. But
why do you
> raise the same error for:
>
> (define v (values 1 2))
Here v is a variable. In a variable definition
(define x 42)
we declare that we want to use the name x for the value 42.
One variable names one value.
>
> For my point of view, we should be able to write:
>
> (call-with-values (lambda ()
> (let ((v (values 1 2)))
> v))
> +)
Here you want v to be name for two values at once.
In stead one can do this:
> (define-values (a b) (values 41 1))
> (+ a b)
42
> (let-values ([(a b) (values 1 2)])
> (values a b))
1
2
--
Jens Axel Søgaard