aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc/cl.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/misc/cl.texi')
-rw-r--r--doc/misc/cl.texi121
1 files changed, 64 insertions, 57 deletions
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index ab54b99138a..d35c14acd1d 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -5,7 +5,7 @@
5@copying 5@copying
6This file documents the GNU Emacs Common Lisp emulation package. 6This file documents the GNU Emacs Common Lisp emulation package.
7 7
8Copyright @copyright{} 1993, 2001-2011 Free Software Foundation, Inc. 8Copyright @copyright{} 1993, 2001-2012 Free Software Foundation, Inc.
9 9
10@quotation 10@quotation
11Permission is granted to copy, distribute and/or modify this document 11Permission is granted to copy, distribute and/or modify this document
@@ -60,17 +60,17 @@ does assume a basic familiarity with Emacs Lisp.
60 60
61@menu 61@menu
62* Overview:: Installation, usage, etc. 62* Overview:: Installation, usage, etc.
63* Program Structure:: Arglists, `eval-when', `defalias' 63* Program Structure:: Arglists, @code{eval-when}, @code{defalias}
64* Predicates:: `typep' and `equalp' 64* Predicates:: @code{typep} and @code{equalp}
65* Control Structure:: `setf', `do', `loop', etc. 65* Control Structure:: @code{setf}, @code{do}, @code{loop}, etc.
66* Macros:: Destructuring, `define-compiler-macro' 66* Macros:: Destructuring, @code{define-compiler-macro}
67* Declarations:: `proclaim', `declare', etc. 67* Declarations:: @code{proclaim}, @code{declare}, etc.
68* Symbols:: Property lists, `gensym' 68* Symbols:: Property lists, @code{gensym}
69* Numbers:: Predicates, functions, random numbers 69* Numbers:: Predicates, functions, random numbers
70* Sequences:: Mapping, functions, searching, sorting 70* Sequences:: Mapping, functions, searching, sorting
71* Lists:: `caddr', `sublis', `member*', `assoc*', etc. 71* Lists:: @code{caddr}, @code{sublis}, @code{member*}, @code{assoc*}, etc.
72* Structures:: `defstruct' 72* Structures:: @code{defstruct}
73* Assertions:: `check-type', `assert', `ignore-errors'. 73* Assertions:: @code{check-type}, @code{assert}, @code{ignore-errors}.
74 74
75* Efficiency Concerns:: Hints and techniques 75* Efficiency Concerns:: Hints and techniques
76* Common Lisp Compatibility:: All known differences with Steele 76* Common Lisp Compatibility:: All known differences with Steele
@@ -128,7 +128,7 @@ features.
128 128
129@item 129@item
130Some features conflict with existing things in Emacs Lisp. For 130Some features conflict with existing things in Emacs Lisp. For
131example, Emacs' @code{assoc} function is incompatible with the 131example, Emacs's @code{assoc} function is incompatible with the
132Common Lisp @code{assoc}. In such cases, this package usually 132Common Lisp @code{assoc}. In such cases, this package usually
133adds the suffix @samp{*} to the function name of the Common 133adds the suffix @samp{*} to the function name of the Common
134Lisp version of the function (e.g., @code{assoc*}). 134Lisp version of the function (e.g., @code{assoc*}).
@@ -293,8 +293,8 @@ do with programs as a whole: advanced argument lists for functions,
293and the @code{eval-when} construct. 293and the @code{eval-when} construct.
294 294
295@menu 295@menu
296* Argument Lists:: `&key', `&aux', `defun*', `defmacro*'. 296* Argument Lists:: @code{&key}, @code{&aux}, @code{defun*}, @code{defmacro*}.
297* Time of Evaluation:: The `eval-when' construct. 297* Time of Evaluation:: The @code{eval-when} construct.
298@end menu 298@end menu
299 299
300@iftex 300@iftex
@@ -683,8 +683,8 @@ This section describes functions for testing whether various
683facts are true or false. 683facts are true or false.
684 684
685@menu 685@menu
686* Type Predicates:: `typep', `deftype', and `coerce' 686* Type Predicates:: @code{typep}, @code{deftype}, and @code{coerce}
687* Equality Predicates:: `equalp' 687* Equality Predicates:: @code{equalp}
688@end menu 688@end menu
689 689
690@node Type Predicates, Equality Predicates, Predicates, Predicates 690@node Type Predicates, Equality Predicates, Predicates, Predicates
@@ -858,14 +858,14 @@ various advanced control structures, including the powerful
858constructs. 858constructs.
859 859
860@menu 860@menu
861* Assignment:: The `psetq' form 861* Assignment:: The @code{psetq} form
862* Generalized Variables:: `setf', `incf', `push', etc. 862* Generalized Variables:: @code{setf}, @code{incf}, @code{push}, etc.
863* Variable Bindings:: `progv', `lexical-let', `flet', `macrolet' 863* Variable Bindings:: @code{progv}, @code{lexical-let}, @code{flet}, @code{macrolet}
864* Conditionals:: `case', `typecase' 864* Conditionals:: @code{case}, @code{typecase}
865* Blocks and Exits:: `block', `return', `return-from' 865* Blocks and Exits:: @code{block}, @code{return}, @code{return-from}
866* Iteration:: `do', `dotimes', `dolist', `do-symbols' 866* Iteration:: @code{do}, @code{dotimes}, @code{dolist}, @code{do-symbols}
867* Loop Facility:: The Common Lisp `loop' macro 867* Loop Facility:: The Common Lisp @code{loop} macro
868* Multiple Values:: `values', `multiple-value-bind', etc. 868* Multiple Values:: @code{values}, @code{multiple-value-bind}, etc.
869@end menu 869@end menu
870 870
871@node Assignment, Generalized Variables, Control Structure, Control Structure 871@node Assignment, Generalized Variables, Control Structure, Control Structure
@@ -929,9 +929,9 @@ Just as certain forms like @code{a[i]} can be lvalues in C, there
929is a set of forms that can be generalized variables in Lisp. 929is a set of forms that can be generalized variables in Lisp.
930 930
931@menu 931@menu
932* Basic Setf:: `setf' and place forms 932* Basic Setf:: @code{setf} and place forms
933* Modify Macros:: `incf', `push', `rotatef', `letf', `callf', etc. 933* Modify Macros:: @code{incf}, @code{push}, @code{rotatef}, @code{letf}, @code{callf}, etc.
934* Customizing Setf:: `define-modify-macro', `defsetf', `define-setf-method' 934* Customizing Setf:: @code{define-modify-macro}, @code{defsetf}, @code{define-setf-method}
935@end menu 935@end menu
936 936
937@node Basic Setf, Modify Macros, Generalized Variables, Generalized Variables 937@node Basic Setf, Modify Macros, Generalized Variables, Generalized Variables
@@ -1540,10 +1540,10 @@ analogous to Lisp's built-in @code{let} form.
1540are also related to variable bindings. 1540are also related to variable bindings.
1541 1541
1542@menu 1542@menu
1543* Dynamic Bindings:: The `progv' form 1543* Dynamic Bindings:: The @code{progv} form
1544* Lexical Bindings:: `lexical-let' and lexical closures 1544* Lexical Bindings:: @code{lexical-let} and lexical closures
1545* Function Bindings:: `flet' and `labels' 1545* Function Bindings:: @code{flet} and @code{labels}
1546* Macro Bindings:: `macrolet' and `symbol-macrolet' 1546* Macro Bindings:: @code{macrolet} and @code{symbol-macrolet}
1547@end menu 1547@end menu
1548 1548
1549@node Dynamic Bindings, Lexical Bindings, Variable Bindings, Variable Bindings 1549@node Dynamic Bindings, Lexical Bindings, Variable Bindings, Variable Bindings
@@ -2094,7 +2094,7 @@ of a list. @var{list} should evaluate to a list; the body @var{forms}
2094are executed with @var{var} bound to each element of the list in 2094are executed with @var{var} bound to each element of the list in
2095turn. Finally, the @var{result} form (or @code{nil}) is evaluated 2095turn. Finally, the @var{result} form (or @code{nil}) is evaluated
2096with @var{var} bound to @code{nil} to produce the result returned by 2096with @var{var} bound to @code{nil} to produce the result returned by
2097the loop. Unlike with Emacs's built in @code{dolist}, the loop is 2097the loop. Unlike with Emacs'ss built in @code{dolist}, the loop is
2098surrounded by an implicit @code{nil} block. 2098surrounded by an implicit @code{nil} block.
2099@end defspec 2099@end defspec
2100 2100
@@ -2104,7 +2104,7 @@ of times. The body is executed with @var{var} bound to the integers
2104from zero (inclusive) to @var{count} (exclusive), in turn. Then 2104from zero (inclusive) to @var{count} (exclusive), in turn. Then
2105the @code{result} form is evaluated with @var{var} bound to the total 2105the @code{result} form is evaluated with @var{var} bound to the total
2106number of iterations that were done (i.e., @code{(max 0 @var{count})}) 2106number of iterations that were done (i.e., @code{(max 0 @var{count})})
2107to get the return value for the loop form. Unlike with Emacs's built in 2107to get the return value for the loop form. Unlike with Emacs'ss built in
2108@code{dolist}, the loop is surrounded by an implicit @code{nil} block. 2108@code{dolist}, the loop is surrounded by an implicit @code{nil} block.
2109@end defspec 2109@end defspec
2110 2110
@@ -2140,12 +2140,12 @@ construct called the ``Loop Facility'' or ``@code{loop} macro,''
2140with an easy-to-use but very powerful and expressive syntax. 2140with an easy-to-use but very powerful and expressive syntax.
2141 2141
2142@menu 2142@menu
2143* Loop Basics:: `loop' macro, basic clause structure 2143* Loop Basics:: @code{loop} macro, basic clause structure
2144* Loop Examples:: Working examples of `loop' macro 2144* Loop Examples:: Working examples of @code{loop} macro
2145* For Clauses:: Clauses introduced by `for' or `as' 2145* For Clauses:: Clauses introduced by @code{for} or @code{as}
2146* Iteration Clauses:: `repeat', `while', `thereis', etc. 2146* Iteration Clauses:: @code{repeat}, @code{while}, @code{thereis}, etc.
2147* Accumulation Clauses:: `collect', `sum', `maximize', etc. 2147* Accumulation Clauses:: @code{collect}, @code{sum}, @code{maximize}, etc.
2148* Other Clauses:: `with', `if', `initially', `finally' 2148* Other Clauses:: @code{with}, @code{if}, @code{initially}, @code{finally}
2149@end menu 2149@end menu
2150 2150
2151@node Loop Basics, Loop Examples, Loop Facility, Loop Facility 2151@node Loop Basics, Loop Examples, Loop Facility, Loop Facility
@@ -2226,7 +2226,7 @@ returned by @code{buffer-list}. For each buffer @code{buf},
2226it calls @code{buffer-file-name} and collects the results into 2226it calls @code{buffer-file-name} and collects the results into
2227a list, which is then returned from the @code{loop} construct. 2227a list, which is then returned from the @code{loop} construct.
2228The result is a list of the file names of all the buffers in 2228The result is a list of the file names of all the buffers in
2229Emacs' memory. The words @code{for}, @code{in}, and @code{collect} 2229Emacs's memory. The words @code{for}, @code{in}, and @code{collect}
2230are reserved words in the @code{loop} language. 2230are reserved words in the @code{loop} language.
2231 2231
2232@example 2232@example
@@ -2586,7 +2586,14 @@ the trailing values are ignored, and if there are more variables
2586than values the trailing variables get the value @code{nil}. 2586than values the trailing variables get the value @code{nil}.
2587If @code{nil} is used as a variable name, the corresponding 2587If @code{nil} is used as a variable name, the corresponding
2588values are ignored. Destructuring may be nested, and dotted 2588values are ignored. Destructuring may be nested, and dotted
2589lists of variables like @code{(x . y)} are allowed. 2589lists of variables like @code{(x . y)} are allowed, so for example
2590to process an alist
2591
2592@example
2593(loop for (key . value) in '((a . 1) (b . 2))
2594 collect value)
2595 @result{} (1 2)
2596@end example
2590 2597
2591@node Iteration Clauses, Accumulation Clauses, For Clauses, Loop Facility 2598@node Iteration Clauses, Accumulation Clauses, For Clauses, Loop Facility
2592@subsection Iteration Clauses 2599@subsection Iteration Clauses
@@ -3177,8 +3184,8 @@ This package defines several symbol-related features that were
3177missing from Emacs Lisp. 3184missing from Emacs Lisp.
3178 3185
3179@menu 3186@menu
3180* Property Lists:: `get*', `remprop', `getf', `remf' 3187* Property Lists:: @code{get*}, @code{remprop}, @code{getf}, @code{remf}
3181* Creating Symbols:: `gensym', `gentemp' 3188* Creating Symbols:: @code{gensym}, @code{gentemp}
3182@end menu 3189@end menu
3183 3190
3184@node Property Lists, Creating Symbols, Symbols, Symbols 3191@node Property Lists, Creating Symbols, Symbols, Symbols
@@ -3323,10 +3330,10 @@ This section defines a few simple Common Lisp operations on numbers
3323which were left out of Emacs Lisp. 3330which were left out of Emacs Lisp.
3324 3331
3325@menu 3332@menu
3326* Predicates on Numbers:: `plusp', `oddp', `floatp-safe', etc. 3333* Predicates on Numbers:: @code{plusp}, @code{oddp}, @code{floatp-safe}, etc.
3327* Numerical Functions:: `abs', `floor*', etc. 3334* Numerical Functions:: @code{abs}, @code{floor*}, etc.
3328* Random Numbers:: `random*', `make-random-state' 3335* Random Numbers:: @code{random*}, @code{make-random-state}
3329* Implementation Parameters:: `most-positive-float' 3336* Implementation Parameters:: @code{most-positive-float}
3330@end menu 3337@end menu
3331 3338
3332@iftex 3339@iftex
@@ -3623,10 +3630,10 @@ Emacs Lisp includes a few of these, notably @code{elt} and
3623 3630
3624@menu 3631@menu
3625* Sequence Basics:: Arguments shared by all sequence functions 3632* Sequence Basics:: Arguments shared by all sequence functions
3626* Mapping over Sequences:: `mapcar*', `mapcan', `map', `every', etc. 3633* Mapping over Sequences:: @code{mapcar*}, @code{mapcan}, @code{map}, @code{every}, etc.
3627* Sequence Functions:: `subseq', `remove*', `substitute', etc. 3634* Sequence Functions:: @code{subseq}, @code{remove*}, @code{substitute}, etc.
3628* Searching Sequences:: `find', `position', `count', `search', etc. 3635* Searching Sequences:: @code{find}, @code{position}, @code{count}, @code{search}, etc.
3629* Sorting Sequences:: `sort*', `stable-sort', `merge' 3636* Sorting Sequences:: @code{sort*}, @code{stable-sort}, @code{merge}
3630@end menu 3637@end menu
3631 3638
3632@node Sequence Basics, Mapping over Sequences, Sequences, Sequences 3639@node Sequence Basics, Mapping over Sequences, Sequences, Sequences
@@ -3863,7 +3870,7 @@ with @var{sequence}.
3863As an extension to Common Lisp, @var{start} and/or @var{end} 3870As an extension to Common Lisp, @var{start} and/or @var{end}
3864may be negative, in which case they represent a distance back 3871may be negative, in which case they represent a distance back
3865from the end of the sequence. This is for compatibility with 3872from the end of the sequence. This is for compatibility with
3866Emacs' @code{substring} function. Note that @code{subseq} is 3873Emacs's @code{substring} function. Note that @code{subseq} is
3867the @emph{only} sequence function that allows negative 3874the @emph{only} sequence function that allows negative
3868@var{start} and @var{end}. 3875@var{start} and @var{end}.
3869 3876
@@ -4052,7 +4059,7 @@ is less than (not equal to) its second argument. For example,
4052for sorting numbers and strings, respectively; @code{>} would sort 4059for sorting numbers and strings, respectively; @code{>} would sort
4053numbers into decreasing rather than increasing order. 4060numbers into decreasing rather than increasing order.
4054 4061
4055This function differs from Emacs' built-in @code{sort} in that it 4062This function differs from Emacs's built-in @code{sort} in that it
4056can operate on any type of sequence, not just lists. Also, it 4063can operate on any type of sequence, not just lists. Also, it
4057accepts a @code{:key} argument which is used to preprocess data 4064accepts a @code{:key} argument which is used to preprocess data
4058fed to the @var{predicate} function. For example, 4065fed to the @var{predicate} function. For example,
@@ -4106,10 +4113,10 @@ a merged sequence which is (stably) sorted according to
4106The functions described here operate on lists. 4113The functions described here operate on lists.
4107 4114
4108@menu 4115@menu
4109* List Functions:: `caddr', `first', `list*', etc. 4116* List Functions:: @code{caddr}, @code{first}, @code{list*}, etc.
4110* Substitution of Expressions:: `subst', `sublis', etc. 4117* Substitution of Expressions:: @code{subst}, @code{sublis}, etc.
4111* Lists as Sets:: `member*', `adjoin', `union', etc. 4118* Lists as Sets:: @code{member*}, @code{adjoin}, @code{union}, etc.
4112* Association Lists:: `assoc*', `rassoc*', `acons', `pairlis' 4119* Association Lists:: @code{assoc*}, @code{rassoc*}, @code{acons}, @code{pairlis}
4113@end menu 4120@end menu
4114 4121
4115@node List Functions, Substitution of Expressions, Lists, Lists 4122@node List Functions, Substitution of Expressions, Lists, Lists
@@ -5179,7 +5186,7 @@ variables no collision can occur.)
5179 5186
5180@xref{Lexical Bindings}, for a description of the @code{lexical-let} 5187@xref{Lexical Bindings}, for a description of the @code{lexical-let}
5181form which establishes a Common Lisp-style lexical binding, and some 5188form which establishes a Common Lisp-style lexical binding, and some
5182examples of how it differs from Emacs' regular @code{let}. 5189examples of how it differs from Emacs's regular @code{let}.
5183 5190
5184@item 5191@item
5185Reader macros. Common Lisp includes a second type of macro that 5192Reader macros. Common Lisp includes a second type of macro that