From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: nisse@lysator.liu.se (Niels =?iso-8859-1?Q?M=F6ller?=) Newsgroups: gmane.lisp.guile.user Subject: Question on mutability of argument lists Date: Wed, 19 Mar 2014 10:34:43 +0100 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1395237650 9845 80.91.229.3 (19 Mar 2014 14:00:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 19 Mar 2014 14:00:50 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Mar 19 15:00:58 2014 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WQH36-0003Xs-C9 for guile-user@m.gmane.org; Wed, 19 Mar 2014 15:00:52 +0100 Original-Received: from localhost ([::1]:41529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQH35-0004vi-U5 for guile-user@m.gmane.org; Wed, 19 Mar 2014 10:00:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQCth-0004da-9L for guile-user@gnu.org; Wed, 19 Mar 2014 05:34:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQCtc-0007O6-Eq for guile-user@gnu.org; Wed, 19 Mar 2014 05:34:53 -0400 Original-Received: from vindbrygga.lysator.liu.se ([2001:6b0:17:f0a0::de]:47534 helo=bacon.lysator.liu.se) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQCtc-0007Nq-4Y for guile-user@gnu.org; Wed, 19 Mar 2014 05:34:48 -0400 Original-Received: from bacon.lysator.liu.se (localhost [127.0.0.1]) by bacon.lysator.liu.se (8.14.5+Sun/8.14.5) with ESMTP id s2J9Yi5Y021689 for ; Wed, 19 Mar 2014 10:34:44 +0100 (MET) Original-Received: (from nisse@localhost) by bacon.lysator.liu.se (8.14.5+Sun/8.14.5/Submit) id s2J9YhiO021688; Wed, 19 Mar 2014 10:34:43 +0100 (MET) X-Authentication-Warning: bacon.lysator.liu.se: nisse set sender to nisse@lysator.liu.se using -f User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (usg-unix-v) X-MIME-Autoconverted: from 8bit to quoted-printable by bacon.lysator.liu.se id s2J9Yi5Y021689 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:6b0:17:f0a0::de X-Mailman-Approved-At: Wed, 19 Mar 2014 10:00:38 -0400 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11134 Archived-At: Hi, I discovered r7rs thanks to the recent guile release announcement. I have one question (which likely applies also to earlier revisions). Not sure what the right forum is, but I hope some of the guile people are familiar with these things and if maybe even can push for some clarification of the spec if needed. I tried mailing to scheme-reports-owner@scheme-reports.org, but that list seems to be member's only). When specifying the use of rest arguments for procedures (r7rs, sec 4.1.4), it seems to imply that the passed argument list is mutable? This is convenient in some ways, e.g., I think the following definition of the list procedure should be correct (define (list . args) args)=20 However, for a natural implementation which evaluates arguments and conses the results up to a list, this seems to require an extra copy of the argument list, after all values are evaluated and before the list is bound to the rest parameter. To see why, assume that evaluation of one of the arguments captures its continuation and returns several times. If this isn't the first argument evaluated, without the extra copying, one gets several calls to the procedure with the rest argument sharing structure, and if the shared part is mutated, things go bad. And since I'd expect that the vast majority of function calls with rest arguments to *not* need any mutability of the argument list, this extra copying seems like an undesirable overhead. On the other hand, if the argument is specified as immutable, then no copying is needed in the common case (as far as I understand, consing up the evaluated arguments will give the correct results no matter how many times the evaluation of a particular argument returns), but instead, the implementation of procedures like list must explicitly construct a new mutable copy of the argument list. It's not obvious if the general description "All objects created by the other procedures listed in this report are mutable." (sec 3.4) applies to the constructed argument lists, so if argument lists for rest parameters really are intended to be mutable, then I think that could be made clearer. I guess the formal semantics section ought to answer the question on whether or not one can get shared structure in argument lists in case evaluation of an argument returns multiple times, but I haven't tried to figure that out... Regards, /Niels M=F6ller --=20 Niels M=F6ller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance.