summaryrefslogtreecommitdiff
path: root/doc/lispref/functions.texi
diff options
context:
space:
mode:
authorPip Cet <pipcet@gmail.com>2020-09-27 16:59:00 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-09-27 16:59:00 +0200
commit433b6fc53dc9511077ed3a8c1ad130196dedbb55 (patch)
treeef369ccea800d0ab2e00cb189bacefa2e9426efa /doc/lispref/functions.texi
parent8d241e8840fdb02dcfce52425626dd8f2125e51a (diff)
downloademacs-433b6fc53dc9511077ed3a8c1ad130196dedbb55.tar.gz
emacs-433b6fc53dc9511077ed3a8c1ad130196dedbb55.tar.bz2
emacs-433b6fc53dc9511077ed3a8c1ad130196dedbb55.zip
Handle single-argument `apply' consistently (bug#40968)
* src/eval.c (Fapply): Handle (apply nil) without crashing. Document single-argument form. * lisp/emacs-lisp/byte-opt.el (byte-optimize-apply): Don't attempt to optimize single-argument apply. * doc/lispref/functions.texi (Calling Functions): Document single-argument apply. Provide example (bug#40968).
Diffstat (limited to 'doc/lispref/functions.texi')
-rw-r--r--doc/lispref/functions.texi10
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index 26b212d05eb..e8e22078d9b 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -762,6 +762,11 @@ arguments, rather than a single list. We say that @code{apply}
@dfn{spreads} this list so that each individual element becomes an
argument.
+@code{apply} with a single argument is special: the first element of
+the argument, which must be a non-empty list, is called as a function
+with the remaining elements as individual arguments. Passing two or
+more arguments will be faster.
+
@code{apply} returns the result of calling @var{function}. As with
@code{funcall}, @var{function} must either be a Lisp function or a
primitive function; special forms and macros do not make sense in
@@ -789,6 +794,11 @@ primitive function; special forms and macros do not make sense in
(apply 'append '((a b c) nil (x y z) nil))
@result{} (a b c x y z)
@end group
+
+@group
+(apply '(+ 3 4))
+ @result{} 7
+@end group
@end example
For an interesting example of using @code{apply}, see @ref{Definition