From: Alan Mackenzie <acm@muc.de>
Subject: Re: How many parameters does an elisp function take?
Date: Fri, 18 Feb 2005 17:43:55 +0000 [thread overview]
Message-ID: <rg95vc.36.ln@acm.acm> (raw)
In-Reply-To: 871xbe9dn9.fsf-monnier+gnu.emacs.help@gnu.org
Stefan Monnier <monnier@iro.umontreal.ca> wrote on Fri, 18 Feb 2005
08:59:24 -0500:
>> 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?
I'd like to fix `beginning-of-defun-raw', where it does (funcall
beginning-of-defun-function). The parameter `arg' from
beginning-of-defun should be passed through to b-o-d-f. We've talked
about this before. Unfortunately, there is no guarantee that existing
user supplied functions can accept an `arg'. I would thus replace the
call with
(if (>= (how-many-params beginnin-of-defun-function) 1)
(funcall beginning-of-defun-function arg)
(funcall beginning-of-defun-function))
> 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).
Exactly.
> 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.
Good idea!
Why is there not such a function in the Emacs core? It seems such an
incredibly useful function, say for debuggers or code-analysers, or for
the uses mentioned above. Did somebody just overlook it in the early
days, perhaps?
> Stefan
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
next prev parent reply other threads:[~2005-02-18 17:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-16 20:11 How many parameters does an elisp function take? Alan Mackenzie
2005-02-16 20:45 ` Kevin Rodgers
2005-02-16 21:02 ` David Kastrup
2005-02-16 23:56 ` Kevin Rodgers
2005-02-18 13:59 ` Stefan Monnier
2005-02-18 17:43 ` Alan Mackenzie [this message]
2005-02-22 14:41 ` Stefan Monnier
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=rg95vc.36.ln@acm.acm \
--to=acm@muc.de \
/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.