emacs-devel
[Top][All Lists]
Advanced

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

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


From: Philipp Stephani
Subject: Re: Arbitrary function: find the number(s) of expected arguments
Date: Sat, 19 Mar 2016 16:14:04 +0000



Eli Zaretskii <address@hidden> schrieb am Sa., 19. März 2016 um 16:44 Uhr:
> For example:
>
> > > (defun f (a b) (list a b))
> > >
> > > (defalias 'g (apply-partially #'f 1))
> > >
> > > what would (func-arity 'g) return?
> >
> > Ideally, it should return (1 . 1).
>
> This signature can be interpreted as "accepts any number of arguments",
> whereby it doesn't.  The condition-case solution with the wrong number
> of args handler at least also catches this case.

But Emacs itself clearly _knows_ that only one argument is acceptable.
So a function that replicates the steps made by the Lisp interpreter
to arrive at this conclusion will be able to reach the same
conclusion.  So I don't see any insoluble problems here.

Knowing the arity in cases like this requires either evaluating the function, or complex parsing of its definition. It is very reasonable to assume that (func-arity 'g) would return (0 . many), because that is g's arity as far as the Lisp interpreter is concerned. 

reply via email to

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