aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorPaul Pogonyshev2016-03-26 11:19:43 +0300
committerEli Zaretskii2016-03-26 11:19:43 +0300
commit6f3243db55e61847784178ea812f28ddf003544a (patch)
treee2bbb4e4c3a49ab661524135c6b1a610580431b8 /doc
parent368b9bb45f125061506d43af4bd4791ab2cfd7b9 (diff)
downloademacs-6f3243db55e61847784178ea812f28ddf003544a.tar.gz
emacs-6f3243db55e61847784178ea812f28ddf003544a.zip
Implement 'func-arity'
* src/eval.c (Ffunc_arity, lambda_arity): New functions. * src/bytecode.c (get_byte_code_arity): New function. * src/lisp.h (get_byte_code_arity): Add prototype. * doc/lispref/functions.texi (What Is a Function): Document 'func-arity'. * etc/NEWS: Mention 'func-arity'. * test/src/fns-tests.el (fns-tests-func-arity): New test set.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/functions.texi40
1 files changed, 34 insertions, 6 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index a2e94c34b62..ff21abba61e 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -143,6 +143,37 @@ function, i.e., can be passed to @code{funcall}. Note that
143and returns @code{nil} for special forms. 143and returns @code{nil} for special forms.
144@end defun 144@end defun
145 145
146 It is also possible to find out how many arguments an arbitrary
147function expects:
148
149@defun func-arity function
150This function provides information about the argument list of the
151specified @var{function}. The returned value is a cons cell of the
152form @w{@code{(@var{min} . @var{max})}}, where @var{min} is the
153minimum number of arguments, and @var{max} is either the maximum
154number of arguments, or the symbol @code{many} for functions with
155@code{&rest} arguments, or the symbol @code{unevalled} if
156@var{function} is a special form.
157
158Note that this function might return inaccurate results in some
159situations, such as the following:
160
161@itemize @minus
162@item
163Functions defined using @code{apply-partially} (@pxref{Calling
164Functions, apply-partially}).
165
166@item
167Functions that are advised using @code{advice-add} (@pxref{Advising
168Named Functions}).
169
170@item
171Functions that determine the argument list dynamically, as part of
172their code.
173@end itemize
174
175@end defun
176
146@noindent 177@noindent
147Unlike @code{functionp}, the next three functions do @emph{not} treat 178Unlike @code{functionp}, the next three functions do @emph{not} treat
148a symbol as its function definition. 179a symbol as its function definition.
@@ -176,12 +207,9 @@ function. For example:
176@end defun 207@end defun
177 208
178@defun subr-arity subr 209@defun subr-arity subr
179This function provides information about the argument list of a 210This works like @code{func-arity}, but only for built-in functions and
180primitive, @var{subr}. The returned value is a pair 211without symbol indirection. It signals an error for non-built-in
181@code{(@var{min} . @var{max})}. @var{min} is the minimum number of 212functions. We recommend to use @code{func-arity} instead.
182args. @var{max} is the maximum number or the symbol @code{many}, for a
183function with @code{&rest} arguments, or the symbol @code{unevalled} if
184@var{subr} is a special form.
185@end defun 213@end defun
186 214
187@node Lambda Expressions 215@node Lambda Expressions