bug-guile
[Top][All Lists]
Advanced

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

Re: GIT version: values writing


From: Hans Aberg
Subject: Re: GIT version: values writing
Date: Thu, 20 Jan 2011 22:55:10 +0100

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 via email to

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