*** empty log message ***
[bpt/emacs.git] / lispref / functions.texi
index edec40d..67d68e4 100644 (file)
@@ -1,6 +1,7 @@
 @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
@@ -63,9 +64,9 @@ the editor.  See @ref{Writing Emacs Primitives}.
 @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
@@ -111,7 +112,6 @@ byte compiler.  @xref{Byte-Code Type}.
 @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
@@ -144,6 +144,16 @@ function.  For example:
 @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
@@ -174,7 +184,7 @@ expression, but to be called as a function.
 @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:
@@ -185,7 +195,7 @@ 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
@@ -354,9 +364,11 @@ is @code{nil}.
   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:
 
@@ -623,7 +635,7 @@ above, it never knows them in the first place.
 @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
@@ -693,7 +705,9 @@ This function ignores any arguments and returns @code{nil}.
 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
@@ -746,6 +760,13 @@ Return the list of results."
 @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.
@@ -871,6 +892,18 @@ do with the list.  Perhaps it will check whether the @sc{car} of the third
 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: