@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999
+@c Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/functions
@node Functions, Macros, Variables, Top
@item lambda expression
A @dfn{lambda expression} is a function written in Lisp.
These are described in the following section.
-@ifinfo
+@ifnottex
@xref{Lambda Expressions}.
-@end ifinfo
+@end ifnottex
@item special form
A @dfn{special form} is a primitive that is like a function but does not
@end table
@defun functionp object
-@tindex functionp
This function returns @code{t} if @var{object} is any kind of function,
or a special form or macro.
@end defun
@end example
@end defun
+@defun subr-arity subr
+@tindex subr-arity
+This function provides information about the argument list of a
+primitive, @var{subr}. The returned value is a pair
+@code{(@var{min} . @var{max})}. @var{min} is the minimum number of
+args. @var{max} is the maximum number or the symbol @code{many}, for a
+function with @code{&rest} arguments, or the symbol @code{unevalled} if
+@var{subr} is a special form.
+@end defun
+
@node Lambda Expressions
@section Lambda Expressions
@cindex lambda expression
@node Lambda Components
@subsection Components of a Lambda Expression
-@ifinfo
+@ifnottex
A function written in Lisp (a ``lambda expression'') is a list that
looks like this:
[@var{interactive-declaration}]
@var{body-forms}@dots{})
@end example
-@end ifinfo
+@end ifnottex
@cindex lambda list
The first element of a lambda expression is always the symbol
There is no way to have required arguments following optional
ones---it would not make sense. To see why this must be so, suppose
that @code{c} in the example were optional and @code{d} were required.
-Suppose three actual arguments are given; which variable would the third
-argument be for? Similarly, it makes no sense to have any more
-arguments (either required or optional) after a @code{&rest} argument.
+Suppose three actual arguments are given; which variable would the
+third argument be for? Would it be used for the @var{c}, or for
+@var{d}? One can argue for both possibilities. Similarly, it makes
+no sense to have any more arguments (either required or optional)
+after a @code{&rest} argument.
Here are some examples of argument lists and proper calls:
@end group
@end example
-Compare these example with the examples of @code{apply}.
+Compare these examples with the examples of @code{apply}.
@end defun
@defun apply function &rest arguments
list or other collection. Emacs Lisp has several such functions;
@code{mapcar} and @code{mapconcat}, which scan a list, are described
here. @xref{Creating Symbols}, for the function @code{mapatoms} which
-maps over the symbols in an obarray.
+maps over the symbols in an obarray. @xref{Hash Access}, for the
+function @code{maphash} which maps over key/value associations in a
+hash table.
These mapping functions do not allow char-tables because a char-table
is a sparse array whose nominal range of indices is very large. To map
@end smallexample
@end defun
+@defun mapc function sequence
+@tindex mapc
+@code{mapc} is like @code{mapcar} except that @var{function} is used for
+side-effects only---the values it returns are ignored, not collected
+into a list. @code{mapc} always returns @var{sequence}.
+@end defun
+
@defun mapconcat function sequence separator
@code{mapconcat} applies @var{function} to each element of
@var{sequence}: the results, which must be strings, are concatenated.
element is the symbol @code{*}! Using @code{function} tells the
compiler it is safe to go ahead and compile the constant function.
+ Nowadays it is possible to omit @code{function} entirely, like this:
+
+@example
+@group
+(defun double-property (symbol prop)
+ (change-property symbol prop (lambda (x) (* 2 x))))
+@end group
+@end example
+
+@noindent
+This is because @code{lambda} itself implies @code{function}.
+
We sometimes write @code{function} instead of @code{quote} when
quoting the name of a function, but this usage is just a sort of
comment: