[r6rs-discuss] "Unspecified"

From: Per Bothner <per>
Date: Mon Oct 2 18:42:00 2006

[To clarify: In the following is not discussing a proposal for R6RS.
I'm discussing ideas I've been thinking about for a Scheme-*like*
language. I agree first-class multiple values are probably not
be a good idea for "Scheme" - but it's an interesting design space.]

Marcin 'Qrczak' Kowalczyk wrote:
> Per Bothner <per_at_bothner.com> writes:
>> If the variable x is bound to multiple values (zero or more than one),
>> the this code would be erroneous. But this is "currently" not possible.
>> So I don't understand your comment.

> Because they are not first-class now; I claim that they wouldn't be
> fully first-class with your modification either. Some code which
> currently accepts any value, would accept any value except the
> multiple-values value. You would introduce exceptions in cases which
> currently have no exceptions.

A somewhat convoluted argument: Because we extend the domain of
"first-class value" to include "multiple values" some code which
before worked for any value will now only work for singleton
values, complicating the specification. Is that your point?
(I'd say it's not different from adding rational integers,
since you have to specify that as vector index has to be an
exact integer rather than any exact number.)

> If you want them to be first-class, just use a list instead.
> What's wrong with a list?

That argument is relevant when discussing whether to include
multiple values in Scheme, but that boat has sailed long ago.

>>> How many values is (values (values 1 2 3) (values 4 5 6))?
>>> What about (values (values 1 2 3))? Here lies madness.
>> No, it is quite consistent (and useful).
>>
>> (values (values 1 2 3) (values 4 5 6)) == (values 1 2 3 4 5 6)
>> (values (values 1 2 3)) == (values 1 2 3)
>
> Then they are even less first-class. Currently if a function returns
> (values x y), then its caller can retrieve x and y back. With your
> modification this would no longer be possible, and we would need to
> invent another way to return two arbitrary values.

It exists: call-with-values.

> BTW, what would be (list (values 1 2))?

If car can contain any first-class value, then there is no reason
it couldn't contain multiple values. In that case
(car (list (values 1 2))) returns the same as (values 1 2).

A more fundamental question is: (- (values 1 2)). It could be:
(1) an error, or
(2) "spliced" yielding (- 1 2) --> -1, or
(3) "distributed" yielding (values (- 1) (- 2)) --> (values -1 -2).

Option (2) is interesting, especially if you combine it with
pattern matching in parameter lists.

But this is getting very off-topic.
-- 
	--Per Bothner
per_at_bothner.com   http://per.bothner.com/
Received on Mon Oct 02 2006 - 18:41:36 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC