unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Hans Aberg <haberg-1@telia.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: bug-guile@gnu.org
Subject: Re: GIT version: values writing
Date: Thu, 20 Jan 2011 22:55:10 +0100	[thread overview]
Message-ID: <EC98E343-DB00-453E-8192-E93CA2D20DC1@telia.com> (raw)
In-Reply-To: <87mxmve0kh.fsf@gnu.org>

On 20 Jan 2011, at 22:18, Ludovic Courtès wrote:

>>>> There seems to be a bug in GIT version when writing the 'values'  
>>>> data
>>>> type.
>>>> (list 2 (values 3 4) 5)
>>>> $1 = (2 3 5)
>>>
>>> This behavior is correct: in Guile 1.9, multiple-value returns are
>>> truncated any time the continuation expects fewer values.
>>>
>>> Here, the ‘values’ call returns 3 values, but the location where  
>>> it’s
>>> called expects only 1, hence the automatic truncation.
>>
>> After the post, I saw that R5RS says the behavior is undefined.
>>
>> However, quietly loosing values is inviting bugs.
>
> I may seem sloppy, but I find it convenient.

In view of that it may break code that relies on the old behavior, I  
think it would be better to throw an exception in the case of multiple  
values.

> In the c.l.s thread you
> mentioned, Joe Marshall writes:
>
>  With the current system, if you wish to add an extra return value,  
> you
>  have to adjust the code at *every* return site (provided you can
>  enumerate all the return sites!).  In Common Lisp, unexpected return
>  values are silently discarded, so modifying a function to return  
> extra
>  information is a local change.  Discarding the extra return values is
>  somewhat sloppy semantically, but far more convenient from a coding
>  standpoint.


It also says:

> With this approach,
>
> > [E]very procedure takes exactly one argument and returns exactly one
> > result.  The argument and the result will always be a sequence.  
> [...]
> > An expression in tail-recursive position returns a one-element
> > sequence.  Continuations accept sequences containing an arbitrary
> > number of elements as results.

This last correspond in infix syntax to combining objects f(x), where  
(x) may be a tuple (x_1, ..., x_k). When f return multiple values, it  
just returns a tuple, so if sent to another function accepting that  
number f arguments, all would work out.

I am implementing this in a syntax on top of Guile, thinking of using  
the old #<values ...> for my tuples.

But as it is not in R5RS, it does not matter. I'm making my own smob.

>> It is discussed here, along with some other ideas.
>>
>> https://groups.google.com/group/comp.lang.scheme/browse_thread/thread/b72d987aa6626cd2/e2f7cfa55fb51d55?hl=en
>
> Interesting thread.

Yes, I am hitting some of those problems rather quickly.




  reply	other threads:[~2011-01-20 21:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-18  9:57 GIT version: values writing Hans Aberg
2011-01-19 14:44 ` GIT version: values Hans Åberg
2011-01-26 20:51   ` Andy Wingo
2011-01-26 23:34     ` Hans Aberg
2011-01-27  9:00       ` Andy Wingo
2011-01-27 13:20         ` Hans Aberg
2011-01-19 17:05 ` Hans Aberg
2011-01-20 15:17   ` Ludovic Courtès
2011-01-20 17:10     ` Hans Aberg
2011-01-19 19:40 ` GIT version: segmentation fault Hans Aberg
2011-01-26 20:46   ` Andy Wingo
2011-01-26 23:37     ` Hans Aberg
2011-01-19 22:22 ` GIT version: missing linking flag Hans Aberg
2011-01-20 15:20   ` Ludovic Courtès
2011-01-20 17:03     ` Hans Aberg
2011-01-20 21:01       ` Ludovic Courtès
2011-01-20 21:13         ` Hans Aberg
2011-01-21 16:02           ` Ludovic Courtès
2011-01-21 17:59             ` Hans Aberg
2011-01-26 20:52               ` Andy Wingo
2011-01-26 23:44                 ` Hans Aberg
2011-01-29 21:47             ` Ludovic Courtès
2011-01-29 22:51               ` Hans Aberg
2011-01-26 20:55       ` Andy Wingo
2011-01-26 23:47         ` Hans Aberg
2011-01-20 15:16 ` GIT version: values writing Ludovic Courtès
2011-01-20 16:51   ` Hans Aberg
2011-01-20 21:18     ` Ludovic Courtès
2011-01-20 21:55       ` Hans Aberg [this message]
2011-01-21 17:13       ` Values extension Hans Aberg
2011-01-26 20:57     ` GIT version: values writing Andy Wingo
2011-01-26 23:50       ` Hans Aberg

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=EC98E343-DB00-453E-8192-E93CA2D20DC1@telia.com \
    --to=haberg-1@telia.com \
    --cc=bug-guile@gnu.org \
    --cc=ludo@gnu.org \
    /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).