Reputation: 20342
I'd like to be able to do:
(function-arity (intern "expt"))
I googled up this solution https://github.com/emacsmirror/parser/blob/master/parser-fn.el
But it's using help-function-arglist
, so it's not exactly straightforward.
I'd like something more solid, preferably rock-solid.
Upvotes: 3
Views: 570
Reputation: 4804
Can't see anything wrong WRT help-function-arglist
, which does it's job here.
While lambda-arity
--pointed at-- seems to have some bugs still.
For example
(optional-arglist (memq '&optional arglist))
should rather use `member '&optional', which would return the remaining list, thus enable counting the elements left.
Upvotes: 1
Reputation: 28541
There's no such thing as a rock-solid function-arity
. In most cases where people want it, what they really want is to call a function in different ways depending on how many arguments it accepts (because its signature is different in different Emacs versions, for example), in which case the approach of "try calling it with many arguments and catch the potential error" is about as good as it gets.
Upvotes: 3