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: Re: Question on mutability of argument lists Date: Wed, 19 Mar 2014 20:56:58 +0100 Message-ID: References: <874n2unmvo.fsf@governatore.luna> <87txauouru.fsf@yeeloong.lan> 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 1395259028 31424 80.91.229.3 (19 Mar 2014 19:57:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 19 Mar 2014 19:57:08 +0000 (UTC) Cc: guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Mar 19 20:57:18 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 1WQMc2-0000bQ-Fq for guile-user@m.gmane.org; Wed, 19 Mar 2014 20:57:18 +0100 Original-Received: from localhost ([::1]:43522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQMc2-0003hB-6G for guile-user@m.gmane.org; Wed, 19 Mar 2014 15:57:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQMbn-0003Yj-6F for guile-user@gnu.org; Wed, 19 Mar 2014 15:57:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQMbm-0008H2-3k for guile-user@gnu.org; Wed, 19 Mar 2014 15:57:03 -0400 Original-Received: from vindbrygga.lysator.liu.se ([2001:6b0:17:f0a0::de]:56532 helo=bacon.lysator.liu.se) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQMbl-0008Gl-C8 for guile-user@gnu.org; Wed, 19 Mar 2014 15:57:02 -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 s2JJux01011891; Wed, 19 Mar 2014 20:56:59 +0100 (MET) Original-Received: (from nisse@localhost) by bacon.lysator.liu.se (8.14.5+Sun/8.14.5/Submit) id s2JJuwJ8011890; Wed, 19 Mar 2014 20:56:58 +0100 (MET) X-Authentication-Warning: bacon.lysator.liu.se: nisse set sender to nisse@lysator.liu.se using -f In-Reply-To: <87txauouru.fsf@yeeloong.lan> (Mark H. Weaver's message of "Wed, 19 Mar 2014 15:25:41 -0400") 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 s2JJux01011891 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:6b0:17:f0a0::de 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:11138 Archived-At: Mark H Weaver writes: > Marco Maggi writes: > >> Yes, but it depends on what is "natural" for you. In >> Vicare, when calling a Scheme function, all the arguments >> are pushed on the Scheme stack segment (similar to calling a >> C function) and then the function is called; the callee >> takes the leftover arguments and puts them into a newly >> allocated list. > > Indeed, and Guile 2 also does this in compiled code. I see. So the allocation of the new list is the responsibility of the function prologue of functions defined with rest arguments. Thanks for the explanation. And somthing similar could be done even if the calling convention is the "natural" one, that the caller conses the arguments onto a list as they are evaluated, and passes that list to the implementation of the procedure. The function prologue in the callee would then extract arguments from that list, and only in the case that the function is defined with a rest argument, the prologue calls list-copy. And the compiler could even omit that list-copy in cases where it can infer that the list cannot be subject to any mutations. (It's long time since I played with lisp/scheme implementation, but then I considered a calling convention where each procedure (and continuation) would have two entry points, one with a single argument passed in a register, and a second entry point where a pointer to an argument list is passed in that register. The first entry point would be used in the common case that there's a single argument or a single return value. While the second entry point would be used when the number of arguments is different from 1. Depending on number of arguments accepted, one or the other of the entry points may point directly to code raising an error). Regards, /Niels --=20 Niels M=F6ller. PGP-encrypted email is preferred. Keyid C0B98E26. Internet email is subject to wholesale government surveillance.