GNU bug report logs -
#17474
Making *unspecified* equivalent to (values) would seem convenient
Previous Next
Full log
View this message in rfc822 format
ludo <at> gnu.org (Ludovic Courtès) writes:
> David Kastrup <dak <at> gnu.org> skribis:
>
>> ludo <at> gnu.org (Ludovic Courtès) writes:
>>
>>> R5RS defines ‘values’ as:
>>>
>>> (define (values . things)
>>> (call-with-current-continuation
>>> (lambda (cont) (apply cont things))))
>>>
>>> Thus, a conforming implementation must raise a run-time error when the
>>> continuation of a (values) form expects one or more values.
>>
>> No. From R5RS:
>>
>> -- procedure: call-with-current-continuation proc
>>
>> [...]
>>
>> The escape procedure accepts the same number of arguments as the
>> continuation to the original call to
>> call-with-current-continuation. Except for continuations created
>> by the `call-with-values' procedure, all continuations take
>> exactly one value. The effect of passing no value or more than
>> one value to continuations that were not created by
>> call-with-values is unspecified.
>
> Oh indeed, I stand corrected.
>
>> So this behavior is neither out of line, nor against the standard. It
>> is merely a more convenient behavior for a situation that the standard
>> left unspecified.
>
> Right.
>
> I’m not completely convinced it makes sense to “specify” the zero values
> case in this way, but I’d like to hear what others think.
The real awkwardness is not when feeding (values) to a single-value
continuation but rather the ability of single-value expressions being
able to pass zero values to a multi-value continuation.
In Guilev1, there was a lot of those around, and indeed
(call-with-values (lambda () (car (list (values)))) list) => ()
in Guilev1.
But in Guile 2.0.9, I actually get the same, and I don't think people
reported bugs for that.
This design does not win a beauty contest. But at least it fits several
parts of Guile and the API together in a less ugly and more satisfactory
manner than before while providing a really large amount of backward
compatibility.
I don't really know whether there are assumptions in the compiler it
might break. So this change would certainly also want testing with
large applications and should not be introduced shortly before a stable
release.
--
David Kastrup
This bug report was last modified 10 years and 16 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.