[gambit-list] strange results using values
Bradley Lucier
lucier at math.purdue.edu
Mon Sep 22 11:35:51 EDT 2008
On Sep 22, 2008, at 11:29 AM, Arthur Smyles wrote:
>
> My use case for using 'values' is to pass a primary value and
> secondary values to a caller. If the caller can only use one value
> then I want it to use the primary value and discard the secondary
> values. So what I would like to see is:
>
> (if (values #f #f) #t #f) => #f
>
> since the primary value is false and the 'if' function can only use
> the primary value.
>
> As it stands now, as a caller of an api that uses 'values', I'd
> have to deal with it as a specialized data structure, in which
> case, the utility of it is very limited since I could just as well
> pass a vector or some other structure.
>
> I think the above semantics could be implemented and still be R5
> compliant.
It sound like you want every place in the program that takes a value
to check whether there are more than one value returned, and pick the
"primary" one.
So if you have
(define (f a b) (+ a b))
(define (g a b) (values a b))
(f (g 0 1) 2)
you'd want the code to f to check that g returned only a single
value, strip out extra ones if it returned more than 1, perhaps
signal an error if g didn't return any values, do something else?
Common Lisp deals with this somehow, but I'm not sure that we want
the semantics of values in Scheme to be complicated so much in able
to implement such a proposal.
Brad
More information about the Gambit-list
mailing list