unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: nisse@lysator.liu.se (Niels Möller)
To: Mark H Weaver <mhw@netris.org>
Cc: guile-user@gnu.org
Subject: Re: Question on mutability of argument lists
Date: Wed, 19 Mar 2014 20:56:58 +0100	[thread overview]
Message-ID: <nnfvmex8qd.fsf@bacon.lysator.liu.se> (raw)
In-Reply-To: <87txauouru.fsf@yeeloong.lan> (Mark H. Weaver's message of "Wed,  19 Mar 2014 15:25:41 -0400")

Mark H Weaver <mhw@netris.org> writes:

> Marco Maggi <marco.maggi-ipsu@poste.it> 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

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.



  reply	other threads:[~2014-03-19 19:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19  9:34 Question on mutability of argument lists Niels Möller
2014-03-19 17:01 ` Marco Maggi
2014-03-19 19:25   ` Mark H Weaver
2014-03-19 19:56     ` Niels Möller [this message]
2014-03-20 10:06       ` [OT] " Marco Maggi
2014-03-20 10:54         ` Niels Möller
2014-03-20 21:02         ` Andy Wingo

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=nnfvmex8qd.fsf@bacon.lysator.liu.se \
    --to=nisse@lysator.liu.se \
    --cc=guile-user@gnu.org \
    --cc=mhw@netris.org \
    /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).