From: Andy Wingo <wingo@pobox.com>
To: Hans Aberg <haberg-1@telia.com>
Cc: bug-guile <bug-guile@gnu.org>
Subject: Re: (+ (values 1 2)) should be 1
Date: Tue, 24 May 2011 17:07:26 +0200 [thread overview]
Message-ID: <m3d3j8nnm9.fsf@unquote.localdomain> (raw)
In-Reply-To: <6B109ACE-F9E4-463D-8314-A19CC40D5B50@telia.com> (Hans Aberg's message of "Tue, 24 May 2011 15:48:32 +0200")
On Tue 24 May 2011 15:48, Hans Aberg <haberg-1@telia.com> writes:
> On 24 May 2011, at 15:11, Andy Wingo wrote:
>
>>> The Guile manual, sec. 10.2.5.2, says that SCM_UNSPECIFIED is to be used when the Scheme standard says the return is an unspecified value.
>>>
>>> So this Lisp extension breaks off from that. If one wants it, > perhaps, there should be some way to invoke it.
>>
>> Hans, you are misreading. (+ 1) is 1 according to the R5RS. (+ "foo")
>> is an error. (+ (values 1 2)) is unspecified, as an instance of
>> returning an unexpected number of values to a continuation, but it is
>> not an instance of the unspecified value.
>
> Andy, I think (values 1 2) should here return SCM_UNSPECIFIED first
> argument to '+', so that people will know that the standard does leave
> the value unspecified.
That is not what the standard says. It says that the effect of
returning an unexpected number of values is unspecified, not that the
*value* is unspecified -- which wouldn't make sense anyway, as they are
multiple values in the first place.
See the R5RS, the R6RS, and the NEWS please.
** Returning multiple values to compiled code will silently truncate the
values to the expected number
For example, the interpreter would raise an error evaluating the form,
`(+ (values 1 2) (values 3 4))', because it would see the operands as
being two compound "values" objects, to which `+' does not apply.
The compiler, on the other hand, receives multiple values on the stack,
not as a compound object. Given that it must check the number of values
anyway, if too many values are provided for a continuation, it chooses
to truncate those values, effectively evaluating `(+ 1 3)' instead.
The idea is that the semantics that the compiler implements is more
intuitive, and the use of the interpreter will fade out with time.
This behavior is allowed both by the R5RS and the R6RS.
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2011-05-24 15:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-22 14:02 (+ (values 1 2)) should be 1 Andy Wingo
2011-05-23 13:34 ` Hans Aberg
2011-05-23 13:49 ` Andy Wingo
2011-05-23 13:58 ` Hans Aberg
2011-05-24 10:35 ` Hans Aberg
2011-05-24 13:11 ` Andy Wingo
2011-05-24 13:48 ` Hans Aberg
2011-05-24 15:07 ` Andy Wingo [this message]
2011-05-24 16:13 ` Hans Aberg
2011-05-25 0:25 ` Mark H Weaver
2011-05-25 8:41 ` Hans Aberg
2011-05-25 16:54 ` Mark H Weaver
2011-05-25 17:10 ` Hans Aberg
2011-06-17 17:43 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3d3j8nnm9.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=bug-guile@gnu.org \
--cc=haberg-1@telia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).