bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17474: Making *unspecified* equivalent to (values) would seem conven


From: David Kastrup
Subject: bug#17474: Making *unspecified* equivalent to (values) would seem convenient
Date: Mon, 12 May 2014 18:58:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

address@hidden (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.

Please reread the last sentence.  "unspecified".  In fact, passing more
than one value to continuations that were not created by
call-with-values already does not raise a runtime error but instead just
drops the additional values:

(+ (values 4 5) 5) => 9

This patch _provides_ a default value when 0 values are given.  That's
filling in a different unspecified behavior than throwing an error, but
Guile already fills in a different unspecified behavior than throwing an
error for multiple values.

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.

-- 
David Kastrup





reply via email to

[Prev in Thread] Current Thread [Next in Thread]