From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: Refer to List of Arguments in Emacs Lisp Function
Date: Thu, 13 Nov 2014 14:23:06 -0500 [thread overview]
Message-ID: <barmar-5EF83B.14230613112014@88-209-239-213.giganet.hu> (raw)
In-Reply-To: mailman.13556.1415895434.1147.help-gnu-emacs@gnu.org
In article <mailman.13556.1415895434.1147.help-gnu-emacs@gnu.org>,
Marcin Borkowski <mbork@wmi.amu.edu.pl> wrote:
> On 2014-11-13, at 09:02, Alexander Shukaev wrote:
>
> > Hello,
> >
> > I can't find whether there is a possibility to refer to the whole list of
> > arguments of a function in Emacs Lisp. For example:
> >
> > (defun move (x y z)
> > (apply do-move (args))
> >
> > What I mean by (args) primitive here is a list (x y z). This use case
> > illustrates usefulness of such a primitive, i.e. forwarding of arguments to
> > another internal call without a need to rewrite them by hand. (length
> > (args)) might be useful in some cases too. Is there anything like that in
> > Emacs Lisp already?
>
> (defun move (&rest args)
> (apply #'do-move args))
>
> Note that (apply do-move (args)) would not work: first, you have to
> quote do-move, second, (args) would try to call a function `args'.
You don't have to quote do-move if it's a variable, e.g. in a context
like:
(let ((do-move (if something #'move1 #'move2)))
(apply do-move (args)))
And I think he was actually asking if there's a function that returns
all the arguments, which you would calls as (args).
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
next prev parent reply other threads:[~2014-11-13 19:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-13 8:02 Refer to List of Arguments in Emacs Lisp Function Alexander Shukaev
2014-11-13 16:16 ` Marcin Borkowski
[not found] ` <mailman.13556.1415895434.1147.help-gnu-emacs@gnu.org>
2014-11-13 19:23 ` Barry Margolin [this message]
[not found] <mailman.13526.1415865742.1147.help-gnu-emacs@gnu.org>
2014-11-13 8:27 ` Joost Kremers
2014-11-13 8:35 ` Alexander Shukaev
2014-11-13 16:58 ` Andreas Röhler
2014-11-14 13:35 ` Nicolas Richard
[not found] ` <mailman.13561.1415897958.1147.help-gnu-emacs@gnu.org>
2014-11-13 19:20 ` Barry Margolin
2014-11-14 1:52 ` Stefan Monnier
2014-11-14 3:56 ` Alexander Shukaev
2014-11-13 16:02 ` Barry Margolin
2014-11-17 11:04 ` Ted Zlatanov
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=barmar-5EF83B.14230613112014@88-209-239-213.giganet.hu \
--to=barmar@alum.mit.edu \
--cc=help-gnu-emacs@gnu.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.