<=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
#ccc solid;padding-left:1ex">
<=
div dir=3D"ltr">Eli Zaretskii <
eliz@gnu.org> schrieb am Sa., 19. M=C3=A4rz 2016 um 17:33=
=C2=A0Uhr:
> From: Philipp Steph=
ani <p.stepha=
ni2@gmail.com>
> Date: Sat, 19 Mar 2016 16:30:30 +0000
> Cc: mich=
ael_heerdegen@web.de, emacs-devel@gnu.org
>
>=C2=A0 No, that's not g's arity:
>
>=C2=A0 (g 10 202 30) =3D> error -> "Wrong number of argument=
s"
>
> This cannot be detected without evaluating the function.
Are we discussing the usefulness of the function, or are we discussing
how best to implement it?
We are discussing for which case=
s it can be implemented. It can be implemented and would be useful for a wi=
de range of functions, such as those defined with defun.
<=
/blockquote>
Example implementation (doesn't work wi=
th macros):
(defun function-arity (function)
=
=C2=A0 (setq function (indirect-function function))
=C2=A0 (=
cl-check-type function function)
=C2=A0 (if (subrp function)
=C2=A0 =C2=A0 =C2=A0 (subr-arity function)
=C2=A0 =C2=A0 (l=
et ((min 0) (max 0) optional)
=C2=A0 =C2=A0 =C2=A0 (dolist (arg (=
help-function-arglist function) (cons min max))
=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 (cond
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((eq max '=
many))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((eq arg '&optio=
nal) (setq optional t))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((eq ar=
g '&rest) (setq max 'many))
=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0(t
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (unless optional =
(cl-incf min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (cl-incf max)))=
))))
--001a1140c8ec8bf9d6052e699b0b--