From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hans Aberg Newsgroups: gmane.lisp.guile.bugs Subject: Re: GIT version: values Date: Thu, 27 Jan 2011 00:34:57 +0100 Message-ID: <29B3FB6E-6F73-40B2-A8D0-DB16B70656BB@telia.com> References: <162CAAE3-D2D8-4894-9B9F-3397348DCFA2@telia.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1296084919 8500 80.91.229.12 (26 Jan 2011 23:35:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 26 Jan 2011 23:35:19 +0000 (UTC) Cc: bug-guile@gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Jan 27 00:35:14 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PiEtN-0000Qk-UD for guile-bugs@m.gmane.org; Thu, 27 Jan 2011 00:35:14 +0100 Original-Received: from localhost ([127.0.0.1]:60264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiEtN-0008FQ-EQ for guile-bugs@m.gmane.org; Wed, 26 Jan 2011 18:35:13 -0500 Original-Received: from [140.186.70.92] (port=38090 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiEtD-0008FI-Ss for bug-guile@gnu.org; Wed, 26 Jan 2011 18:35:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PiEtC-0007HL-Kg for bug-guile@gnu.org; Wed, 26 Jan 2011 18:35:03 -0500 Original-Received: from smtp-out11.han.skanova.net ([195.67.226.200]:54756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PiEtC-0007H0-AZ for bug-guile@gnu.org; Wed, 26 Jan 2011 18:35:02 -0500 Original-Received: from [10.0.1.199] (217.210.127.13) by smtp-out11.han.skanova.net (8.5.133) (authenticated as u26619196) id 4D0756AC00E5BA73; Thu, 27 Jan 2011 00:35:01 +0100 In-Reply-To: X-Mailer: Apple Mail (2.936) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5043 Archived-At: 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.