[plt-scheme] Multiple values

From: Gregory Woodhouse (gregory.woodhouse at sbcglobal.net)
Date: Mon Feb 20 16:06:08 EST 2006

On Feb 20, 2006, at 10:24 AM, Geoffrey Knauth wrote:

> On Feb 20, 2006, at 12:49, hufflen jean-michel wrote:
>> 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))
>
> Jens answered the technical question.  I don't know the  
> philosophical answer, but I remember this line from a song, though  
> I forget who sang it:  "How can you be in two places at once when  
> you're not anywhere at all?"
>
> Geoffrey

Without looking at the manual, as a newcomer, I would have expected  
(+ 0 (values 1 2)) to evaluate to something like (values 1 2) (i.e.,  
to provide a kind of non-determinism).

Looking at the manual, I find it difficult to see how multiple values  
could be used in a program, except perhaps in conjunction with let- 
values, as in

(let-values (((x y) (values 1 2))) (+ x y))

but I'm not sure whether this is equivalent to

(let ((x 1) (y 2)) (+ x y))

or

(let ((x 1))
     (let ((y 2))
       (+ x y)))

or perhaps neither.

I realize that the above expressions are operationally equivalent,  
but (for now, anyway) I implement them differently in my evaluator,

===
Gregory Woodhouse
gregory.woodhouse at sbcglobal.net

"Education is a progressive discovery
of our own ignorance."
--Will Durant





Posted on the users mailing list.