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

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

Re: How many parameters does an elisp function take?


From: Stefan Monnier
Subject: Re: How many parameters does an elisp function take?
Date: Fri, 18 Feb 2005 08:59:24 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> Is it possible to determine at run time how many parameters an elisp
> function takes?  For example, I'd like to write something like:

> (how-many-params 'null)

> and have it evaluate to 1.  Or something like that.  Together with some
> reasonable convention for indicating &optional and &rest arguments.

Why do you want to know?

Every time this has shown up for me, what I truly wanted to know was more
like "can I call this with 4 args?", and the reason why I wanted to know was
to know whether to call it with 4 args or otherwise do something else
(e.g. call it with fewer args).

In practice, it's simpler to just do

    (condition-case nil
        (fooo)
      (wrong-number-of-arguments
        (bar)))

It's not perfect, but I've found it to suffer from fewer problems than
other solutions.  It's also faster.


        Stefan


reply via email to

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