help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Refer to List of Arguments in Emacs Lisp Function


From: Barry Margolin
Subject: Re: Refer to List of Arguments in Emacs Lisp Function
Date: Thu, 13 Nov 2014 14:23:06 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

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 ***


reply via email to

[Prev in Thread] Current Thread [Next in Thread]