[gambit-list] strange results using values
Arthur Smyles
atsmyles at earthlink.net
Mon Sep 22 14:27:52 EDT 2008
Not exactly,
The definition of values given by the spec is:
The R5RS's definition of values:
(define (values . things)
(call-with-current-continuation
(lambda (cont) (apply cont things))))
Let's say you can have 2 types of continuations:
1. Single value continuations
2. multi-value continuations.
If the current continuation is a single value continuation, then only return one value, otherwise for a multi-value continuation (created with call-with-values) send all the arguments. The behavior could then be like:
(define (values . things)
(call-with-current-continuation
(lambda (cont)
(if (mv-continuation? cont)
(apply cont things)
(apply cont (car things) '())))))
In the case of (values), I'd leave that unspecified.
Arthur
----- Original Message ----
From: Bradley Lucier <lucier at math.purdue.edu>
To: Arthur Smyles <atsmyles at earthlink.net>
Cc: Bradley Lucier <lucier at math.purdue.edu>; Marc Feeley <feeley at iro.umontreal.ca>; gambit-list at iro.umontreal.ca
Sent: Monday, September 22, 2008 11:35:51 AM
Subject: Re: [gambit-list] strange results using values
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