unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Hans Aberg <haberg-1@telia.com>
To: Andy Wingo <wingo@pobox.com>
Cc: bug-guile@gnu.org
Subject: Re: GIT version: values
Date: Thu, 27 Jan 2011 00:34:57 +0100	[thread overview]
Message-ID: <29B3FB6E-6F73-40B2-A8D0-DB16B70656BB@telia.com> (raw)
In-Reply-To: <m3vd1bcrsz.fsf@unquote.localdomain>

On 26 Jan 2011, at 21:51, Andy Wingo wrote:

>> It seems it is not only 'values' writing, but the new behavior  
>> seems to
>> be to strip trailing values quietly:
>>  (define a (values 2 3 4))
>>  (call-with-values (lambda () a) (lambda x x))
>> in Guile 1.9.14.68-a7d8a computes to
>>  $1 = (2)
>>
>> By contrast, in guile-1.8.8, it computes to
>>  (2 3 4)
>
> Indeed.  This and a (hopefully small) number of other differences are
> noted in the NEWS.
...
> There is no tuple with multiple-valued returns: they are returned on  
> the
> stack.

Right. I was implementing infix notation tuples syntax f(x_1, ...,  
x_k) using Bison on top of Guile, relying on the old behavior of  
'values'. It is possible to extend Scheme values as to infix tuples  
usage:

Think of Scheme (f x_1 ... x_k) as equivalent to f(x_1 ... x_k), and  
add the reduction of tuples singletons (x) = x. Then (f (values  
x_1 ... x_k)) is the same as f((x_1 ... x_k)) = f(x_1 ... x_k), that  
is (f x_1 ... x_k). However, if more than one of the x_i in is a non- 
singleton, it is an iterated tuple which cannot be reduced on its  
topmost level.

In addition, I extended so that if f = (f_1, ..., f_n), then f(x) is  
defined to (f_1(x), ..., f_n(x)). For values, ((values f_1 ... f_n)  
x_1 ... x_k) computes to (values (f_1 x_1 ... x_k) ... (f_n x_1 ...  
x_k)). With this syntax, one can write (atan ((values sin cos) x)).

Also, functions that return no value might just as well return  
(values) instead of an internal unspecified value. They will then work  
as in C/C++.

> Both of these behaviors are allowed by R5RS and R6RS.

This is correct.

> The compiler's
>    behavior is more correct, however. If you wish to preserve a  
> potentially
>    multiply-valued return, you will need to set up a multiple-value
>    continuation, using `call-with-values'.

But this is false. It prevents implementing tuples in Scheme, at least  
using 'values'.

The topic is discussed here:
https://groups.google.com/group/comp.lang.scheme/browse_thread/thread/b72d987aa6626cd2/e2f7cfa55fb51d55?hl=en

It mentions the above:
 > [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.




  reply	other threads:[~2011-01-26 23:34 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 [this message]
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
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=29B3FB6E-6F73-40B2-A8D0-DB16B70656BB@telia.com \
    --to=haberg-1@telia.com \
    --cc=bug-guile@gnu.org \
    --cc=wingo@pobox.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).