[Top][All Lists]

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

Re: Arbitrary function: find the number(s) of expected arguments

From: Paul Pogonyshev
Subject: Re: Arbitrary function: find the number(s) of expected arguments
Date: Sat, 26 Mar 2016 12:42:17 +0100

Eli Zaretskii wrote:
> > In the attached patch I modified `doc/lispref/functions.texi': text about
> > `subr-arity' is moved to a new section above about `func-arity' and
> > adapted as needed. `subr-arity' is still in the documentation, but I
> > replaced its description with an advice to use `func-arity' instead. Is
> > that enough?
> It's enough, but in the future please also provide a NEWS entry, like
> the one I added.
> > Do you still need changelog entries? Long time since I committed
> > anything to Emacs, maybe you finally got rid of them (I hope)?
> We no longer maintain ChangeLog files in the repository, but we do
> request commit log messages in the ChangeLog format, so please do
> provide them in the future.  (I wrote them for you this time.)


> I pushed the changes to the master branch, thanks.

Thank you.

> There's one potential issue left:
>  (func-arity 'with-temp-buffer) => error-> Invalid function: with-temp-buffer
> Is it possible to support macros as well?  If not, how about producing
> a more meaningful error message?

Well, according to `functionp' macros are not functions, so it's
sort of correct.  On the other hand, it seems (symbol-function ...)
works, returning ('macro . FUNCTION) for them.  However, I can't
find any real C-level way to handle macros, e.g. `macrop' is even
not a builtin.

Or is just treating them as lists fine?  If so, we could add
something like this (untested):

diff --git a/src/eval.c b/src/eval.c
index 64a6655..5c594b8 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2958,6 +2958,9 @@ function with `&rest' args, or `unevalled' for a special form.  */)
       && (function = XSYMBOL (function)->function, SYMBOLP (function)))
     function = indirect_function (function);
+  if (CONSP (function) && EQ (XCAR (function), Qmacro))
+    function = XCDR (function);
   if (SUBRP (function))
     result = Fsubr_arity (function);
   else if (COMPILEDP (function))

However, I'm not exactly sure what will happen with autoloaded


reply via email to

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