[r6rs-discuss] multiple values and mathematicians

Derick Eddington derick.eddington at gmail.com
Fri Feb 20 06:15:01 EST 2009


On Thu, 2009-02-19 at 12:03 -0500, Bradley Lucier wrote:
> As Brian is surely aware, his definition of values and call-with-values

> doesn't match the current definition of values since right now
> 
> (values x) => x

[snip]

> perhaps "values" in Scheme does have a strong connection to
> mathematics.


On Thu, 2009-02-19 at 11:51 -0600, Alan Watson wrote:
> Brad,
> 
> While you're right that Brian's suggestion failed in the trivial case  
> of (values x), I think you can write values and call-with-values in  
> terms of other primitives given suitable records.

[snip]

> I think the  
> ability to implement multiple values in terms of records means that we  
> can usefully debate whether they might better be accommodated in a  
> library rather than the core language.


I use multiple return values when the purpose of a procedure is to
return multiple things which are immediately operated on or which are
intended to go separate ways.  I suppose I'd be just as happy with an
optimizeable destructuring binding macro, except for one thing: zero
return values.

Zero return values and implicitly dropping extra values are not
reasonably possible with library-provided "values records" returned as a
"normal / core" single value, are they?

I like returning `(values)' for things which logically return no value,
because it seems robust in the spirit of "detect errors as soon as
possible" if such things are accidentally used at a continuation that
takes a value.  I don't think I want some value which means "zero return
values" (empty list, empty "values record", or whatever) to be silently
taken, I think I want an exception raised saying this happened and
preventing the program from continuing so that some "zero return values"
value cannot accidentally be used, especially in the cases where any
value is allowed and assumed to be what you intended to give -- who
knows how long such mistakes will go undetected for and how confusing
they will be if/when they eventually break something.

(I know R6RS says: "The effect of passing an inappropriate number of
values to [a continuation implicitly accepting a single value] is
undefined.", but there are implementations which prevent it, and it
looks like I lean towards them.)

When I was first learning Scheme, my initial impression of any number of
return values was and still is that the symmetry between it and any
number of procedure arguments is obvious and so it's a natural fit.
Just as it makes sense to me we should be able to give any number of
inputs to a procedure, we should be able to give any number of outputs.
I didn't know there was disagreement about this until recently.

If you don't like any number of return values, can't you ignore it and
always use one return value without problems?

-- 
: Derick
----------------------------------------------------------------




More information about the r6rs-discuss mailing list