aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-10-23 00:43:39 -0700
committerGlenn Morris2012-10-23 00:43:39 -0700
commit8d6510b95a6bde1e605da1bc5e582dab06cff51d (patch)
treeda7607fa0d24b628286557168ddcf82fdeabd440
parent49238e7f5c081b841bdc57d96599c4997dcb487c (diff)
downloademacs-8d6510b95a6bde1e605da1bc5e582dab06cff51d.tar.gz
emacs-8d6510b95a6bde1e605da1bc5e582dab06cff51d.zip
Start updating cl.texi for cl-lib changes
* doc/misc/cl.texi: Include emacsver.texi. Use Emacs version number rather than unchanging cl.el version number. End all menu descriptions with a period. Do not use @dfn{CL} for every instance of "CL". (Overview): Remove no-runtime caveat, and note about foo* names. (Usage): Use cl-lib rather than cl. (Organization, Naming Conventions): Update for cl-lib.el. (Installation): Remove long-irrelevant node. (Program Structure, Predicates, Control Structure): Start updating for cl-lib namespace. * doc/misc/Makefile.in ($(buildinfodir)/cl$(INFO_EXT), cl.dvi, cl.pdf): Depend on emacsver.texi.
-rw-r--r--doc/misc/ChangeLog16
-rw-r--r--doc/misc/Makefile.in6
-rw-r--r--doc/misc/cl.texi425
3 files changed, 219 insertions, 228 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 3ee183ff255..6f70139df58 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,19 @@
12012-10-23 Glenn Morris <rgm@gnu.org>
2
3 * cl.texi: Include emacsver.texi. Use Emacs version number rather
4 than unchanging cl.el version number.
5 End all menu descriptions with a period.
6 Do not use @dfn{CL} for every instance of "CL".
7 (Overview): Remove no-runtime caveat, and note about foo* names.
8 (Usage): Use cl-lib rather than cl.
9 (Organization, Naming Conventions): Update for cl-lib.el.
10 (Installation): Remove long-irrelevant node.
11 (Program Structure, Predicates, Control Structure):
12 Start updating for cl-lib namespace.
13
14 * Makefile.in ($(buildinfodir)/cl$(INFO_EXT), cl.dvi, cl.pdf):
15 Depend on emacsver.texi.
16
12012-10-09 Michael Albinus <michael.albinus@gmx.de> 172012-10-09 Michael Albinus <michael.albinus@gmx.de>
2 18
3 * trampver.texi: Update release number. 19 * trampver.texi: Update release number.
diff --git a/doc/misc/Makefile.in b/doc/misc/Makefile.in
index 5ce6d82e683..ea1e87333bd 100644
--- a/doc/misc/Makefile.in
+++ b/doc/misc/Makefile.in
@@ -237,12 +237,12 @@ cc-mode.pdf: ${srcdir}/cc-mode.texi
237 $(ENVADD) $(TEXI2PDF) ${srcdir}/cc-mode.texi 237 $(ENVADD) $(TEXI2PDF) ${srcdir}/cc-mode.texi
238 238
239cl : $(buildinfodir)/cl$(INFO_EXT) 239cl : $(buildinfodir)/cl$(INFO_EXT)
240$(buildinfodir)/cl$(INFO_EXT): ${srcdir}/cl.texi 240$(buildinfodir)/cl$(INFO_EXT): ${srcdir}/cl.texi $(emacsdir)/emacsver.texi
241 $(mkinfodir) 241 $(mkinfodir)
242 $(MAKEINFO) $(MAKEINFO_OPTS) $(INFO_OPTS) -o $@ ${srcdir}/cl.texi 242 $(MAKEINFO) $(MAKEINFO_OPTS) $(INFO_OPTS) -o $@ ${srcdir}/cl.texi
243cl.dvi: ${srcdir}/cl.texi 243cl.dvi: ${srcdir}/cl.texi $(emacsdir)/emacsver.texi
244 $(ENVADD) $(TEXI2DVI) ${srcdir}/cl.texi 244 $(ENVADD) $(TEXI2DVI) ${srcdir}/cl.texi
245cl.pdf: ${srcdir}/cl.texi 245cl.pdf: ${srcdir}/cl.texi $(emacsdir)/emacsver.texi
246 $(ENVADD) $(TEXI2PDF) ${srcdir}/cl.texi 246 $(ENVADD) $(TEXI2PDF) ${srcdir}/cl.texi
247 247
248dbus : $(buildinfodir)/dbus$(INFO_EXT) 248dbus : $(buildinfodir)/dbus$(INFO_EXT)
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 18abb0647a2..12fd76e2e1c 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -1,6 +1,7 @@
1\input texinfo @c -*-texinfo-*- 1\input texinfo @c -*-texinfo-*-
2@setfilename ../../info/cl 2@setfilename ../../info/cl
3@settitle Common Lisp Extensions 3@settitle Common Lisp Extensions
4@include emacsver.texi
4 5
5@copying 6@copying
6This file documents the GNU Emacs Common Lisp emulation package. 7This file documents the GNU Emacs Common Lisp emulation package.
@@ -34,7 +35,7 @@ developing GNU and promoting software freedom.''
34@sp 4 35@sp 4
35@center For GNU Emacs Lisp 36@center For GNU Emacs Lisp
36@sp 1 37@sp 1
37@center Version 2.02 38@center as distributed with Emacs @value{EMACSVER}
38@sp 5 39@sp 5
39@center Dave Gillespie 40@center Dave Gillespie
40@center daveg@@synaptics.com 41@center daveg@@synaptics.com
@@ -53,23 +54,23 @@ developing GNU and promoting software freedom.''
53@end ifnottex 54@end ifnottex
54 55
55@menu 56@menu
56* Overview:: Installation, usage, etc. 57* Overview:: Basics, usage, etc.
57* Program Structure:: Arglists, @code{eval-when}, @code{defalias} 58* Program Structure:: Arglists, @code{cl-eval-when}, @code{defalias}.
58* Predicates:: @code{typep} and @code{equalp} 59* Predicates:: @code{cl-typep} and @code{cl-equalp}.
59* Control Structure:: @code{setf}, @code{do}, @code{loop}, etc. 60* Control Structure:: @code{setf}, @code{cl-do}, @code{cl-loop}, etc.
60* Macros:: Destructuring, @code{define-compiler-macro} 61* Macros:: Destructuring, @code{cl-define-compiler-macro}.
61* Declarations:: @code{proclaim}, @code{declare}, etc. 62* Declarations:: @code{cl-proclaim}, @code{cl-declare}, etc.
62* Symbols:: Property lists, @code{gensym} 63* Symbols:: Property lists, @code{cl-gensym}.
63* Numbers:: Predicates, functions, random numbers 64* Numbers:: Predicates, functions, random numbers.
64* Sequences:: Mapping, functions, searching, sorting 65* Sequences:: Mapping, functions, searching, sorting.
65* Lists:: @code{caddr}, @code{sublis}, @code{member*}, @code{assoc*}, etc. 66* Lists:: @code{cl-caddr}, @code{cl-sublis}, @code{cl-member}, @code{cl-assoc}, etc.
66* Structures:: @code{defstruct} 67* Structures:: @code{cl-defstruct}.
67* Assertions:: @code{check-type}, @code{assert}, @code{ignore-errors}. 68* Assertions:: @code{cl-check-type}, @code{cl-assert}, @code{ignore-errors}.
68 69
69* Efficiency Concerns:: Hints and techniques 70* Efficiency Concerns:: Hints and techniques.
70* Common Lisp Compatibility:: All known differences with Steele 71* Common Lisp Compatibility:: All known differences with Steele.
71* Old CL Compatibility:: All known differences with old cl.el 72* Old CL Compatibility:: All known differences with old cl.el.
72* Porting Common Lisp:: Hints for porting Common Lisp code 73* Porting Common Lisp:: Hints for porting Common Lisp code.
73 74
74* GNU Free Documentation License:: The license for this documentation. 75* GNU Free Documentation License:: The license for this documentation.
75* Function Index:: 76* Function Index::
@@ -92,21 +93,11 @@ As Emacs Lisp programmers have grown in number, and the applications
92they write have grown more ambitious, it has become clear that Emacs 93they write have grown more ambitious, it has become clear that Emacs
93Lisp could benefit from many of the conveniences of Common Lisp. 94Lisp could benefit from many of the conveniences of Common Lisp.
94 95
95The @dfn{CL} package adds a number of Common Lisp functions and 96The @code{CL} package adds a number of Common Lisp functions and
96control structures to Emacs Lisp. While not a 100% complete 97control structures to Emacs Lisp. While not a 100% complete
97implementation of Common Lisp, @dfn{CL} adds enough functionality 98implementation of Common Lisp, @code{CL} adds enough functionality
98to make Emacs Lisp programming significantly more convenient. 99to make Emacs Lisp programming significantly more convenient.
99 100
100@strong{Please note:} the @dfn{CL} functions are not standard parts of
101the Emacs Lisp name space, so it is legitimate for users to define
102them with other, conflicting meanings. To avoid conflicting with
103those user activities, we have a policy that packages installed in
104Emacs must not load @dfn{CL} at run time. (It is ok for them to load
105@dfn{CL} at compile time only, with @code{eval-when-compile}, and use
106the macros it provides.) If you are writing packages that you plan to
107distribute and invite widespread use for, you might want to observe
108the same rule.
109
110Some Common Lisp features have been omitted from this package 101Some Common Lisp features have been omitted from this package
111for various reasons: 102for various reasons:
112 103
@@ -119,152 +110,131 @@ examples of this group.
119@item 110@item
120Other features cannot be implemented without modification to the 111Other features cannot be implemented without modification to the
121Emacs Lisp interpreter itself, such as multiple return values, 112Emacs Lisp interpreter itself, such as multiple return values,
122lexical scoping, case-insensitive symbols, and complex numbers. 113case-insensitive symbols, and complex numbers.
123The @dfn{CL} package generally makes no attempt to emulate these 114The @code{CL} package generally makes no attempt to emulate these
124features. 115features.
125 116
126@item
127Some features conflict with existing things in Emacs Lisp. For
128example, Emacs's @code{assoc} function is incompatible with the
129Common Lisp @code{assoc}. In such cases, this package usually
130adds the suffix @samp{*} to the function name of the Common
131Lisp version of the function (e.g., @code{assoc*}).
132@end itemize 117@end itemize
133 118
134The package described here was written by Dave Gillespie, 119The package described here was originally written by Dave Gillespie,
135@file{daveg@@synaptics.com}. It is a total rewrite of the original 120@file{daveg@@synaptics.com}, as a total rewrite of an earlier
1361986 @file{cl.el} package by Cesar Quiroz. Most features of the 1211986 @file{cl.el} package by Cesar Quiroz. Most features of the
137Quiroz package have been retained; any incompatibilities are 122Quiroz package were retained; any incompatibilities are
138noted in the descriptions below. Care has been taken in this 123noted in the descriptions below. Care has been taken in this
139version to ensure that each function is defined efficiently, 124version to ensure that each function is defined efficiently,
140concisely, and with minimal impact on the rest of the Emacs 125concisely, and with minimal impact on the rest of the Emacs
141environment. 126environment. Stefan Monnier added the file @file{cl-lib.el} and
127rationalized the namespace for Emacs 24.3.
142 128
143@menu 129@menu
144* Usage:: How to use the CL package 130* Usage:: How to use the CL package.
145* Organization:: The package's five component files 131* Organization:: The package's five component files.
146* Installation:: Compiling and installing CL 132* Naming Conventions:: Notes on CL function names.
147* Naming Conventions:: Notes on CL function names
148@end menu 133@end menu
149 134
150@node Usage 135@node Usage
151@section Usage 136@section Usage
152 137
153@noindent 138@noindent
154Lisp code that uses features from the @dfn{CL} package should 139The @code{CL} package is distributed with Emacs, so there is no need
155include at the beginning: 140to install any additional files in order to start using it. Lisp code
141that uses features from the @code{CL} package should simply include at
142the beginning:
156 143
157@example 144@example
158(require 'cl) 145(require 'cl-lib)
159@end example 146@end example
160 147
161@noindent 148@noindent
162It is safe to arrange to load @dfn{CL} at all times, e.g., 149You may wish to add such a statement to your init file, if you
163in your @file{.emacs} file. But it's a good idea, for portability, 150make frequent use of CL features.
164to @code{(require 'cl)} in your code even if you do this.
165 151
166@node Organization 152@node Organization
167@section Organization 153@section Organization
168 154
169@noindent 155@noindent
170The Common Lisp package is organized into four files: 156The Common Lisp package is organized into four main files:
171 157
172@table @file 158@table @file
173@item cl.el 159@item cl-lib.el
174This is the ``main'' file, which contains basic functions 160This is the main file, which contains basic functions
175and information about the package. This file is relatively 161and information about the package. This file is relatively compact.
176compact---about 700 lines.
177 162
178@item cl-extra.el 163@item cl-extra.el
179This file contains the larger, more complex or unusual functions. 164This file contains the larger, more complex or unusual functions.
180It is kept separate so that packages which only want to use Common 165It is kept separate so that packages which only want to use Common
181Lisp fundamentals like the @code{cadr} function won't need to pay 166Lisp fundamentals like the @code{cl-incf} function won't need to pay
182the overhead of loading the more advanced functions. 167the overhead of loading the more advanced functions.
183 168
184@item cl-seq.el 169@item cl-seq.el
185This file contains most of the advanced functions for operating 170This file contains most of the advanced functions for operating
186on sequences or lists, such as @code{delete-if} and @code{assoc*}. 171on sequences or lists, such as @code{cl-delete-if} and @code{cl-assoc}.
187 172
188@item cl-macs.el 173@item cl-macs.el
189This file contains the features of the packages which are macros 174This file contains the features that are macros instead of functions.
190instead of functions. Macros expand when the caller is compiled, 175Macros expand when the caller is compiled, not when it is run, so the
191not when it is run, so the macros generally only need to be 176macros generally only need to be present when the byte-compiler is
192present when the byte-compiler is running (or when the macros are 177running (or when the macros are used in uncompiled code). Most of the
193used in uncompiled code such as a @file{.emacs} file). Most of 178macros of this package are isolated in @file{cl-macs.el} so that they
194the macros of this package are isolated in @file{cl-macs.el} so 179won't take up memory unless you are compiling.
195that they won't take up memory unless you are compiling.
196@end table 180@end table
197 181
198The file @file{cl.el} includes all necessary @code{autoload} 182The file @file{cl-lib.el} includes all necessary @code{autoload}
199commands for the functions and macros in the other three files. 183commands for the functions and macros in the other three files.
200All you have to do is @code{(require 'cl)}, and @file{cl.el} 184All you have to do is @code{(require 'cl-lib)}, and @file{cl-lib.el}
201will take care of pulling in the other files when they are 185will take care of pulling in the other files when they are
202needed. 186needed.
203 187
204There is another file, @file{cl-compat.el}, which defines some 188There is another file, @file{cl.el}, which was the main entry point
205routines from the older @file{cl.el} package that are not otherwise 189to the CL package prior to Emacs 24.3. Nowadays, it is replaced
190by @file{cl-lib.el}. The two provide the same features, but use
191different function names (in fact, @file{cl.el} just defines aliases
192to the @file{cl-lib.el} definitions). In particular, the old @file{cl.el}
193does not use a clean namespace. For this reason, Emacs has a policy
194that packages distributed with Emacs must not load @code{cl} at run time.
195(It is ok for them to load @code{cl} at @emph{compile} time, with
196@code{eval-when-compile}, and use the macros it provides.) There is
197no such restriction on the use of @code{cl-lib}. New code should use
198@code{cl-lib} rather than @code{cl}. @xref{Naming Conventions}.
199
200There is one more file, @file{cl-compat.el}, which defines some
201routines from the older CL package that are not otherwise
206present in the new package. This includes internal routines 202present in the new package. This includes internal routines
207like @code{setelt} and @code{zip-lists}, deprecated features 203like @code{setelt} and @code{zip-lists}, deprecated features
208like @code{defkeyword}, and an emulation of the old-style 204like @code{defkeyword}, and an emulation of the old-style
209multiple-values feature. This file is obsolete and should not be used 205multiple-values feature. This file is obsolete and should not be used
210in new code. @xref{Old CL Compatibility}. 206in new code. @xref{Old CL Compatibility}.
211 207
212@node Installation
213@section Installation
214
215@noindent
216The @dfn{CL} package is distributed with Emacs, so there is no need
217to install anything.
218
219If you do need to install it, just put the byte-compiled files
220@file{cl.elc}, @file{cl-extra.elc}, @file{cl-seq.elc},
221@file{cl-macs.elc}, and (if necessary) @file{cl-compat.elc} into a
222directory on your @code{load-path}. Also, format the @file{cl.texi}
223file and put the resulting Info files into a directory in your
224@code{Info-directory-list}.
225
226@node Naming Conventions 208@node Naming Conventions
227@section Naming Conventions 209@section Naming Conventions
228 210
229@noindent 211@noindent
230Except where noted, all functions defined by this package have the 212Except where noted, all functions defined by this package have the
231same names and calling conventions as their Common Lisp counterparts. 213same calling conventions as their Common Lisp counterparts, and
232 214names that are those of Common Lisp plus a @samp{cl-} prefix.
233Following is a complete list of functions whose names were changed
234from Common Lisp, usually to avoid conflicts with Emacs. In each
235case, a @samp{*} has been appended to the Common Lisp name to obtain
236the Emacs name:
237
238@example
239defun* defsubst* defmacro* function*
240member* assoc* rassoc* get*
241remove* delete* mapcar* sort*
242floor* ceiling* truncate* round*
243mod* rem* random*
244@end example
245 215
246Internal function and variable names in the package are prefixed 216Internal function and variable names in the package are prefixed
247by @code{cl-}. Here is a complete list of functions @emph{not} 217by @code{cl--}. Here is a complete list of functions prefixed by
248prefixed by @code{cl-} which were not taken from Common Lisp: 218@code{cl-} that were not taken from Common Lisp:
249 219
220@c FIXME lexical-let lexical-let*
250@example 221@example
251floatp-safe lexical-let lexical-let* 222cl-callf cl-callf2 cl-defsubst
252callf callf2 letf letf* 223cl-floatp-safe cl-letf cl-letf*
253defsubst*
254@end example 224@end example
255 225
256The following simple functions and macros are defined in @file{cl.el}; 226The following simple functions and macros are defined in @file{cl-lib.el};
257they do not cause other components like @file{cl-extra} to be loaded. 227they do not cause other components like @file{cl-extra} to be loaded.
258 228
259@example 229@example
260floatp-safe endp 230cl-floatp-safe cl-endp
261evenp oddp plusp minusp 231cl-evenp cl-oddp cl-plusp cl-minusp
262caaar .. cddddr 232cl-caaar .. cl-cddddr
263list* ldiff rest first .. tenth 233cl-list* cl-ldiff cl-rest cl-first .. cl-tenth
264copy-list subst mapcar* [2] 234cl-copy-list cl-subst cl-mapcar [2]
265adjoin [3] acons pairlis pop [4] 235cl-adjoin [3] cl-acons cl-pairlis
266push [4] pushnew [3,4] incf [4] decf [4] 236cl-pushnew [3,4] cl-incf [4] cl-decf [4]
267proclaim declaim 237cl-proclaim cl-declaim
268@end example 238@end example
269 239
270@noindent 240@noindent
@@ -281,13 +251,13 @@ and @code{:key} is not used.
281@chapter Program Structure 251@chapter Program Structure
282 252
283@noindent 253@noindent
284This section describes features of the @dfn{CL} package which have to 254This section describes features of the @code{CL} package that have to
285do with programs as a whole: advanced argument lists for functions, 255do with programs as a whole: advanced argument lists for functions,
286and the @code{eval-when} construct. 256and the @code{cl-eval-when} construct.
287 257
288@menu 258@menu
289* Argument Lists:: @code{&key}, @code{&aux}, @code{defun*}, @code{defmacro*}. 259* Argument Lists:: @code{&key}, @code{&aux}, @code{cl-defun}, @code{cl-defmacro}.
290* Time of Evaluation:: The @code{eval-when} construct. 260* Time of Evaluation:: The @code{cl-eval-when} construct.
291@end menu 261@end menu
292 262
293@iftex 263@iftex
@@ -309,26 +279,26 @@ this package to implement Common Lisp argument lists seamlessly.
309Instead, this package defines alternates for several Lisp forms 279Instead, this package defines alternates for several Lisp forms
310which you must use if you need Common Lisp argument lists. 280which you must use if you need Common Lisp argument lists.
311 281
312@defspec defun* name arglist body... 282@defspec cl-defun name arglist body...
313This form is identical to the regular @code{defun} form, except 283This form is identical to the regular @code{defun} form, except
314that @var{arglist} is allowed to be a full Common Lisp argument 284that @var{arglist} is allowed to be a full Common Lisp argument
315list. Also, the function body is enclosed in an implicit block 285list. Also, the function body is enclosed in an implicit block
316called @var{name}; @pxref{Blocks and Exits}. 286called @var{name}; @pxref{Blocks and Exits}.
317@end defspec 287@end defspec
318 288
319@defspec defsubst* name arglist body... 289@defspec cl-defsubst name arglist body...
320This is just like @code{defun*}, except that the function that 290This is just like @code{cl-defun}, except that the function that
321is defined is automatically proclaimed @code{inline}, i.e., 291is defined is automatically proclaimed @code{inline}, i.e.,
322calls to it may be expanded into in-line code by the byte compiler. 292calls to it may be expanded into in-line code by the byte compiler.
323This is analogous to the @code{defsubst} form; 293This is analogous to the @code{defsubst} form;
324@code{defsubst*} uses a different method (compiler macros) which 294@code{cl-defsubst} uses a different method (compiler macros) which
325works in all versions of Emacs, and also generates somewhat more 295works in all versions of Emacs, and also generates somewhat more
326efficient inline expansions. In particular, @code{defsubst*} 296efficient inline expansions. In particular, @code{cl-defsubst}
327arranges for the processing of keyword arguments, default values, 297arranges for the processing of keyword arguments, default values,
328etc., to be done at compile-time whenever possible. 298etc., to be done at compile-time whenever possible.
329@end defspec 299@end defspec
330 300
331@defspec defmacro* name arglist body... 301@defspec cl-defmacro name arglist body...
332This is identical to the regular @code{defmacro} form, 302This is identical to the regular @code{defmacro} form,
333except that @var{arglist} is allowed to be a full Common Lisp 303except that @var{arglist} is allowed to be a full Common Lisp
334argument list. The @code{&environment} keyword is supported as 304argument list. The @code{&environment} keyword is supported as
@@ -339,19 +309,19 @@ The macro expander body is enclosed in an implicit block called
339@var{name}. 309@var{name}.
340@end defspec 310@end defspec
341 311
342@defspec function* symbol-or-lambda 312@defspec cl-function symbol-or-lambda
343This is identical to the regular @code{function} form, 313This is identical to the regular @code{function} form,
344except that if the argument is a @code{lambda} form then that 314except that if the argument is a @code{lambda} form then that
345form may use a full Common Lisp argument list. 315form may use a full Common Lisp argument list.
346@end defspec 316@end defspec
347 317
348Also, all forms (such as @code{defsetf} and @code{flet}) defined 318Also, all forms (such as @code{cl-flet} and @code{cl-labels}) defined
349in this package that include @var{arglist}s in their syntax allow 319in this package that include @var{arglist}s in their syntax allow
350full Common Lisp argument lists. 320full Common Lisp argument lists.
351 321
352Note that it is @emph{not} necessary to use @code{defun*} in 322Note that it is @emph{not} necessary to use @code{cl-defun} in
353order to have access to most @dfn{CL} features in your function. 323order to have access to most @code{CL} features in your function.
354These features are always present; @code{defun*}'s only 324These features are always present; @code{cl-defun}'s only
355difference from @code{defun} is its more flexible argument 325difference from @code{defun} is its more flexible argument
356lists and its implicit block. 326lists and its implicit block.
357 327
@@ -401,7 +371,7 @@ are optional arguments which are specified by name rather than
401positionally in the argument list. For example, 371positionally in the argument list. For example,
402 372
403@example 373@example
404(defun* foo (a &optional b &key c d (e 17))) 374(cl-defun foo (a &optional b &key c d (e 17)))
405@end example 375@end example
406 376
407@noindent 377@noindent
@@ -427,7 +397,7 @@ You can also explicitly specify the keyword argument; it need not be
427simply the variable name prefixed with a colon. For example, 397simply the variable name prefixed with a colon. For example,
428 398
429@example 399@example
430(defun* bar (&key (a 1) ((baz b) 4))) 400(cl-defun bar (&key (a 1) ((baz b) 4)))
431@end example 401@end example
432 402
433@noindent 403@noindent
@@ -453,16 +423,16 @@ the ``rest'' argument is bound to the keyword list as it appears
453in the call. For example: 423in the call. For example:
454 424
455@smallexample 425@smallexample
456(defun* find-thing (thing &rest rest &key need &allow-other-keys) 426(cl-defun find-thing (thing &rest rest &key need &allow-other-keys)
457 (or (apply 'member* thing thing-list :allow-other-keys t rest) 427 (or (apply 'cl-member thing thing-list :allow-other-keys t rest)
458 (if need (error "Thing not found")))) 428 (if need (error "Thing not found"))))
459@end smallexample 429@end smallexample
460 430
461@noindent 431@noindent
462This function takes a @code{:need} keyword argument, but also 432This function takes a @code{:need} keyword argument, but also
463accepts other keyword arguments which are passed on to the 433accepts other keyword arguments which are passed on to the
464@code{member*} function. @code{allow-other-keys} is used to 434@code{cl-member} function. @code{allow-other-keys} is used to
465keep both @code{find-thing} and @code{member*} from complaining 435keep both @code{find-thing} and @code{cl-member} from complaining
466about each others' keywords in the arguments. 436about each others' keywords in the arguments.
467 437
468The fifth section of the argument list consists of @dfn{auxiliary 438The fifth section of the argument list consists of @dfn{auxiliary
@@ -473,17 +443,17 @@ difference between the following two functions, except for a
473matter of stylistic taste: 443matter of stylistic taste:
474 444
475@example 445@example
476(defun* foo (a b &aux (c (+ a b)) d) 446(cl-defun foo (a b &aux (c (+ a b)) d)
477 @var{body}) 447 @var{body})
478 448
479(defun* foo (a b) 449(cl-defun foo (a b)
480 (let ((c (+ a b)) d) 450 (let ((c (+ a b)) d)
481 @var{body})) 451 @var{body}))
482@end example 452@end example
483 453
484Argument lists support @dfn{destructuring}. In Common Lisp, 454Argument lists support @dfn{destructuring}. In Common Lisp,
485destructuring is only allowed with @code{defmacro}; this package 455destructuring is only allowed with @code{defmacro}; this package
486allows it with @code{defun*} and other argument lists as well. 456allows it with @code{cl-defun} and other argument lists as well.
487In destructuring, any argument variable (@var{var} in the above 457In destructuring, any argument variable (@var{var} in the above
488diagram) can be replaced by a list of variables, or more generally, 458diagram) can be replaced by a list of variables, or more generally,
489a recursive argument list. The corresponding argument value must 459a recursive argument list. The corresponding argument value must
@@ -491,7 +461,7 @@ be a list whose elements match this recursive argument list.
491For example: 461For example:
492 462
493@example 463@example
494(defmacro* dolist ((var listform &optional resultform) 464(cl-defmacro dolist ((var listform &optional resultform)
495 &rest body) 465 &rest body)
496 ...) 466 ...)
497@end example 467@end example
@@ -532,21 +502,21 @@ For example, the compiler effectively evaluates @code{defmacro} forms
532at compile-time so that later parts of the file can refer to the 502at compile-time so that later parts of the file can refer to the
533macros that are defined. 503macros that are defined.
534 504
535@defspec eval-when (situations...) forms... 505@defspec cl-eval-when (situations...) forms...
536This form controls when the body @var{forms} are evaluated. 506This form controls when the body @var{forms} are evaluated.
537The @var{situations} list may contain any set of the symbols 507The @var{situations} list may contain any set of the symbols
538@code{compile}, @code{load}, and @code{eval} (or their long-winded 508@code{compile}, @code{load}, and @code{eval} (or their long-winded
539ANSI equivalents, @code{:compile-toplevel}, @code{:load-toplevel}, 509ANSI equivalents, @code{:compile-toplevel}, @code{:load-toplevel},
540and @code{:execute}). 510and @code{:execute}).
541 511
542The @code{eval-when} form is handled differently depending on 512The @code{cl-eval-when} form is handled differently depending on
543whether or not it is being compiled as a top-level form. 513whether or not it is being compiled as a top-level form.
544Specifically, it gets special treatment if it is being compiled 514Specifically, it gets special treatment if it is being compiled
545by a command such as @code{byte-compile-file} which compiles files 515by a command such as @code{byte-compile-file} which compiles files
546or buffers of code, and it appears either literally at the 516or buffers of code, and it appears either literally at the
547top level of the file or inside a top-level @code{progn}. 517top level of the file or inside a top-level @code{progn}.
548 518
549For compiled top-level @code{eval-when}s, the body @var{forms} are 519For compiled top-level @code{cl-eval-when}s, the body @var{forms} are
550executed at compile-time if @code{compile} is in the @var{situations} 520executed at compile-time if @code{compile} is in the @var{situations}
551list, and the @var{forms} are written out to the file (to be executed 521list, and the @var{forms} are written out to the file (to be executed
552at load-time) if @code{load} is in the @var{situations} list. 522at load-time) if @code{load} is in the @var{situations} list.
@@ -554,11 +524,11 @@ at load-time) if @code{load} is in the @var{situations} list.
554For non-compiled-top-level forms, only the @code{eval} situation is 524For non-compiled-top-level forms, only the @code{eval} situation is
555relevant. (This includes forms executed by the interpreter, forms 525relevant. (This includes forms executed by the interpreter, forms
556compiled with @code{byte-compile} rather than @code{byte-compile-file}, 526compiled with @code{byte-compile} rather than @code{byte-compile-file},
557and non-top-level forms.) The @code{eval-when} acts like a 527and non-top-level forms.) The @code{cl-eval-when} acts like a
558@code{progn} if @code{eval} is specified, and like @code{nil} 528@code{progn} if @code{eval} is specified, and like @code{nil}
559(ignoring the body @var{forms}) if not. 529(ignoring the body @var{forms}) if not.
560 530
561The rules become more subtle when @code{eval-when}s are nested; 531The rules become more subtle when @code{cl-eval-when}s are nested;
562consult Steele (second edition) for the gruesome details (and 532consult Steele (second edition) for the gruesome details (and
563some gruesome examples). 533some gruesome examples).
564 534
@@ -566,13 +536,13 @@ Some simple examples:
566 536
567@example 537@example
568;; Top-level forms in foo.el: 538;; Top-level forms in foo.el:
569(eval-when (compile) (setq foo1 'bar)) 539(cl-eval-when (compile) (setq foo1 'bar))
570(eval-when (load) (setq foo2 'bar)) 540(cl-eval-when (load) (setq foo2 'bar))
571(eval-when (compile load) (setq foo3 'bar)) 541(cl-eval-when (compile load) (setq foo3 'bar))
572(eval-when (eval) (setq foo4 'bar)) 542(cl-eval-when (eval) (setq foo4 'bar))
573(eval-when (eval compile) (setq foo5 'bar)) 543(cl-eval-when (eval compile) (setq foo5 'bar))
574(eval-when (eval load) (setq foo6 'bar)) 544(cl-eval-when (eval load) (setq foo6 'bar))
575(eval-when (eval compile load) (setq foo7 'bar)) 545(cl-eval-when (eval compile load) (setq foo7 'bar))
576@end example 546@end example
577 547
578When @file{foo.el} is compiled, these variables will be set during 548When @file{foo.el} is compiled, these variables will be set during
@@ -595,18 +565,18 @@ be set:
595foo4 foo5 foo6 foo7 ; `eval' 565foo4 foo5 foo6 foo7 ; `eval'
596@end example 566@end example
597 567
598If these seven @code{eval-when}s had been, say, inside a @code{defun}, 568If these seven @code{cl-eval-when}s had been, say, inside a @code{defun},
599then the first three would have been equivalent to @code{nil} and the 569then the first three would have been equivalent to @code{nil} and the
600last four would have been equivalent to the corresponding @code{setq}s. 570last four would have been equivalent to the corresponding @code{setq}s.
601 571
602Note that @code{(eval-when (load eval) @dots{})} is equivalent 572Note that @code{(cl-eval-when (load eval) @dots{})} is equivalent
603to @code{(progn @dots{})} in all contexts. The compiler treats 573to @code{(progn @dots{})} in all contexts. The compiler treats
604certain top-level forms, like @code{defmacro} (sort-of) and 574certain top-level forms, like @code{defmacro} (sort-of) and
605@code{require}, as if they were wrapped in @code{(eval-when 575@code{require}, as if they were wrapped in @code{(eval-when
606(compile load eval) @dots{})}. 576(compile load eval) @dots{})}.
607@end defspec 577@end defspec
608 578
609Emacs includes two special forms related to @code{eval-when}. 579Emacs includes two special forms related to @code{cl-eval-when}.
610One of these, @code{eval-when-compile}, is not quite equivalent to 580One of these, @code{eval-when-compile}, is not quite equivalent to
611any @code{eval-when} construct and is described below. 581any @code{eval-when} construct and is described below.
612 582
@@ -625,7 +595,7 @@ or other reasons.
625This form is similar to the @samp{#.} syntax of true Common Lisp. 595This form is similar to the @samp{#.} syntax of true Common Lisp.
626@end defspec 596@end defspec
627 597
628@defspec load-time-value form 598@defspec cl-load-time-value form
629The @var{form} is evaluated at load-time; at execution time, 599The @var{form} is evaluated at load-time; at execution time,
630this form acts like a quoted constant of the resulting value. 600this form acts like a quoted constant of the resulting value.
631 601
@@ -633,12 +603,12 @@ Early Common Lisp had a @samp{#,} syntax that was similar to
633this, but ANSI Common Lisp replaced it with @code{load-time-value} 603this, but ANSI Common Lisp replaced it with @code{load-time-value}
634and gave it more well-defined semantics. 604and gave it more well-defined semantics.
635 605
636In a compiled file, @code{load-time-value} arranges for @var{form} 606In a compiled file, @code{cl-load-time-value} arranges for @var{form}
637to be evaluated when the @file{.elc} file is loaded and then used 607to be evaluated when the @file{.elc} file is loaded and then used
638as if it were a quoted constant. In code compiled by 608as if it were a quoted constant. In code compiled by
639@code{byte-compile} rather than @code{byte-compile-file}, the 609@code{byte-compile} rather than @code{byte-compile-file}, the
640effect is identical to @code{eval-when-compile}. In uncompiled 610effect is identical to @code{eval-when-compile}. In uncompiled
641code, both @code{eval-when-compile} and @code{load-time-value} 611code, both @code{eval-when-compile} and @code{cl-load-time-value}
642act exactly like @code{progn}. 612act exactly like @code{progn}.
643 613
644@example 614@example
@@ -649,7 +619,7 @@ act exactly like @code{progn}.
649 (eval-when-compile (current-time-string)) 619 (eval-when-compile (current-time-string))
650 ;; or '#.(current-time-string) in real Common Lisp 620 ;; or '#.(current-time-string) in real Common Lisp
651 ", and loaded on: " 621 ", and loaded on: "
652 (load-time-value (current-time-string)))) 622 (cl-load-time-value (current-time-string))))
653@end example 623@end example
654 624
655@noindent 625@noindent
@@ -676,21 +646,21 @@ This section describes functions for testing whether various
676facts are true or false. 646facts are true or false.
677 647
678@menu 648@menu
679* Type Predicates:: @code{typep}, @code{deftype}, and @code{coerce} 649* Type Predicates:: @code{cl-typep}, @code{cl-deftype}, and @code{cl-coerce}.
680* Equality Predicates:: @code{equalp} 650* Equality Predicates:: @code{cl-equalp}.
681@end menu 651@end menu
682 652
683@node Type Predicates 653@node Type Predicates
684@section Type Predicates 654@section Type Predicates
685 655
686@noindent 656@noindent
687The @dfn{CL} package defines a version of the Common Lisp @code{typep} 657The @code{CL} package defines a version of the Common Lisp @code{typep}
688predicate. 658predicate.
689 659
690@defun typep object type 660@defun cl-typep object type
691Check if @var{object} is of type @var{type}, where @var{type} is a 661Check if @var{object} is of type @var{type}, where @var{type} is a
692(quoted) type name of the sort used by Common Lisp. For example, 662(quoted) type name of the sort used by Common Lisp. For example,
693@code{(typep foo 'integer)} is equivalent to @code{(integerp foo)}. 663@code{(cl-typep foo 'integer)} is equivalent to @code{(integerp foo)}.
694@end defun 664@end defun
695 665
696The @var{type} argument to the above function is either a symbol 666The @var{type} argument to the above function is either a symbol
@@ -705,18 +675,18 @@ than @samp{-p} are used when appropriate.)
705 675
706@item 676@item
707The type symbol @code{t} stands for the union of all types. 677The type symbol @code{t} stands for the union of all types.
708@code{(typep @var{object} t)} is always true. Likewise, the 678@code{(cl-typep @var{object} t)} is always true. Likewise, the
709type symbol @code{nil} stands for nothing at all, and 679type symbol @code{nil} stands for nothing at all, and
710@code{(typep @var{object} nil)} is always false. 680@code{(cl-typep @var{object} nil)} is always false.
711 681
712@item 682@item
713The type symbol @code{null} represents the symbol @code{nil}. 683The type symbol @code{null} represents the symbol @code{nil}.
714Thus @code{(typep @var{object} 'null)} is equivalent to 684Thus @code{(cl-typep @var{object} 'null)} is equivalent to
715@code{(null @var{object})}. 685@code{(null @var{object})}.
716 686
717@item 687@item
718The type symbol @code{atom} represents all objects that are not cons 688The type symbol @code{atom} represents all objects that are not cons
719cells. Thus @code{(typep @var{object} 'atom)} is equivalent to 689cells. Thus @code{(cl-typep @var{object} 'atom)} is equivalent to
720@code{(atom @var{object})}. 690@code{(atom @var{object})}.
721 691
722@item 692@item
@@ -728,7 +698,7 @@ The type symbols @code{character} and @code{string-char} match
728integers in the range from 0 to 255. 698integers in the range from 0 to 255.
729 699
730@item 700@item
731The type symbol @code{float} uses the @code{floatp-safe} predicate 701The type symbol @code{float} uses the @code{cl-floatp-safe} predicate
732defined by this package rather than @code{floatp}, so it will work 702defined by this package rather than @code{floatp}, so it will work
733correctly even in Emacs versions without floating-point support. 703correctly even in Emacs versions without floating-point support.
734 704
@@ -750,7 +720,7 @@ combinations of types. For example, @code{(or integer (float 0 *))}
750represents all objects that are integers or non-negative floats. 720represents all objects that are integers or non-negative floats.
751 721
752@item 722@item
753Lists beginning with @code{member} or @code{member*} represent 723Lists beginning with @code{member} or @code{cl-member} represent
754objects @code{eql} to any of the following values. For example, 724objects @code{eql} to any of the following values. For example,
755@code{(member 1 2 3 4)} is equivalent to @code{(integer 1 4)}, 725@code{(member 1 2 3 4)} is equivalent to @code{(integer 1 4)},
756and @code{(member nil)} is equivalent to @code{null}. 726and @code{(member nil)} is equivalent to @code{null}.
@@ -762,9 +732,9 @@ with that object as an argument.
762@end itemize 732@end itemize
763 733
764The following function and macro (not technically predicates) are 734The following function and macro (not technically predicates) are
765related to @code{typep}. 735related to @code{cl-typep}.
766 736
767@defun coerce object type 737@defun cl-coerce object type
768This function attempts to convert @var{object} to the specified 738This function attempts to convert @var{object} to the specified
769@var{type}. If @var{object} is already of that type as determined by 739@var{type}. If @var{object} is already of that type as determined by
770@code{typep}, it is simply returned. Otherwise, certain types of 740@code{typep}, it is simply returned. Otherwise, certain types of
@@ -774,28 +744,28 @@ converted to that type if possible. If @var{type} is
774@code{character}, then strings of length one and symbols with 744@code{character}, then strings of length one and symbols with
775one-character names can be coerced. If @var{type} is @code{float}, 745one-character names can be coerced. If @var{type} is @code{float},
776then integers can be coerced in versions of Emacs that support 746then integers can be coerced in versions of Emacs that support
777floats. In all other circumstances, @code{coerce} signals an 747floats. In all other circumstances, @code{cl-coerce} signals an
778error. 748error.
779@end defun 749@end defun
780 750
781@defspec deftype name arglist forms... 751@defspec cl-deftype name arglist forms...
782This macro defines a new type called @var{name}. It is similar 752This macro defines a new type called @var{name}. It is similar
783to @code{defmacro} in many ways; when @var{name} is encountered 753to @code{defmacro} in many ways; when @var{name} is encountered
784as a type name, the body @var{forms} are evaluated and should 754as a type name, the body @var{forms} are evaluated and should
785return a type specifier that is equivalent to the type. The 755return a type specifier that is equivalent to the type. The
786@var{arglist} is a Common Lisp argument list of the sort accepted 756@var{arglist} is a Common Lisp argument list of the sort accepted
787by @code{defmacro*}. The type specifier @samp{(@var{name} @var{args}...)} 757by @code{cl-defmacro}. The type specifier @samp{(@var{name} @var{args}...)}
788is expanded by calling the expander with those arguments; the type 758is expanded by calling the expander with those arguments; the type
789symbol @samp{@var{name}} is expanded by calling the expander with 759symbol @samp{@var{name}} is expanded by calling the expander with
790no arguments. The @var{arglist} is processed the same as for 760no arguments. The @var{arglist} is processed the same as for
791@code{defmacro*} except that optional arguments without explicit 761@code{cl-defmacro} except that optional arguments without explicit
792defaults use @code{*} instead of @code{nil} as the ``default'' 762defaults use @code{*} instead of @code{nil} as the ``default''
793default. Some examples: 763default. Some examples:
794 764
795@example 765@example
796(deftype null () '(satisfies null)) ; predefined 766(cl-deftype null () '(satisfies null)) ; predefined
797(deftype list () '(or null cons)) ; predefined 767(cl-deftype list () '(or null cons)) ; predefined
798(deftype unsigned-byte (&optional bits) 768(cl-deftype unsigned-byte (&optional bits)
799 (list 'integer 0 (if (eq bits '*) bits (1- (lsh 1 bits))))) 769 (list 'integer 0 (if (eq bits '*) bits (1- (lsh 1 bits)))))
800(unsigned-byte 8) @equiv{} (integer 0 255) 770(unsigned-byte 8) @equiv{} (integer 0 255)
801(unsigned-byte) @equiv{} (integer 0 *) 771(unsigned-byte) @equiv{} (integer 0 *)
@@ -808,21 +778,21 @@ type specifier could be implemented if desired; this package does
808not implement @code{unsigned-byte} by default. 778not implement @code{unsigned-byte} by default.
809@end defspec 779@end defspec
810 780
811The @code{typecase} and @code{check-type} macros also use type 781The @code{cl-typecase} and @code{cl-check-type} macros also use type
812names. @xref{Conditionals}. @xref{Assertions}. The @code{map}, 782names. @xref{Conditionals}. @xref{Assertions}. The @code{cl-map},
813@code{concatenate}, and @code{merge} functions take type-name 783@code{cl-concatenate}, and @code{cl-merge} functions take type-name
814arguments to specify the type of sequence to return. @xref{Sequences}. 784arguments to specify the type of sequence to return. @xref{Sequences}.
815 785
816@node Equality Predicates 786@node Equality Predicates
817@section Equality Predicates 787@section Equality Predicates
818 788
819@noindent 789@noindent
820This package defines the Common Lisp predicate @code{equalp}. 790This package defines the Common Lisp predicate @code{cl-equalp}.
821 791
822@defun equalp a b 792@defun cl-equalp a b
823This function is a more flexible version of @code{equal}. In 793This function is a more flexible version of @code{equal}. In
824particular, it compares strings case-insensitively, and it compares 794particular, it compares strings case-insensitively, and it compares
825numbers without regard to type (so that @code{(equalp 3 3.0)} is 795numbers without regard to type (so that @code{(cl-equalp 3 3.0)} is
826true). Vectors and conses are compared recursively. All other 796true). Vectors and conses are compared recursively. All other
827objects are compared as if by @code{equal}. 797objects are compared as if by @code{equal}.
828 798
@@ -831,15 +801,15 @@ respects. First, Common Lisp's @code{equalp} also compares
831@emph{characters} case-insensitively, which would be impractical 801@emph{characters} case-insensitively, which would be impractical
832in this package since Emacs does not distinguish between integers 802in this package since Emacs does not distinguish between integers
833and characters. In keeping with the idea that strings are less 803and characters. In keeping with the idea that strings are less
834vector-like in Emacs Lisp, this package's @code{equalp} also will 804vector-like in Emacs Lisp, this package's @code{cl-equalp} also will
835not compare strings against vectors of integers. 805not compare strings against vectors of integers.
836@end defun 806@end defun
837 807
838Also note that the Common Lisp functions @code{member} and @code{assoc} 808Also note that the Common Lisp functions @code{member} and @code{assoc}
839use @code{eql} to compare elements, whereas Emacs Lisp follows the 809use @code{eql} to compare elements, whereas Emacs Lisp follows the
840MacLisp tradition and uses @code{equal} for these two functions. 810MacLisp tradition and uses @code{equal} for these two functions.
841In Emacs, use @code{member*} and @code{assoc*} to get functions 811In Emacs, use @code{memq} (or @code{cl-member}) and @code{assq} (or
842which use @code{eql} for comparisons. 812@code{cl-assoc}) to get functions which use @code{eql} for comparisons.
843 813
844@node Control Structure 814@node Control Structure
845@chapter Control Structure 815@chapter Control Structure
@@ -847,28 +817,32 @@ which use @code{eql} for comparisons.
847@noindent 817@noindent
848The features described in the following sections implement 818The features described in the following sections implement
849various advanced control structures, including the powerful 819various advanced control structures, including the powerful
820@c FIXME setf is now in gv.el, not cl.
850@code{setf} facility and a number of looping and conditional 821@code{setf} facility and a number of looping and conditional
851constructs. 822constructs.
852 823
824@c FIXME setf, push are standard now.
825@c lexical-let is obsolete; flet is not cl-flet.
826@c values is not cl-values.
853@menu 827@menu
854* Assignment:: The @code{psetq} form 828* Assignment:: The @code{cl-psetq} form.
855* Generalized Variables:: @code{setf}, @code{incf}, @code{push}, etc. 829* Generalized Variables:: @code{setf}, @code{cl-incf}, @code{push}, etc.
856* Variable Bindings:: @code{progv}, @code{lexical-let}, @code{flet}, @code{macrolet} 830* Variable Bindings:: @code{cl-progv}, @code{lexical-let}, @code{flet}, @code{cl-macrolet}.
857* Conditionals:: @code{case}, @code{typecase} 831* Conditionals:: @code{cl-case}, @code{cl-typecase}.
858* Blocks and Exits:: @code{block}, @code{return}, @code{return-from} 832* Blocks and Exits:: @code{cl-block}, @code{cl-return}, @code{cl-return-from}.
859* Iteration:: @code{do}, @code{dotimes}, @code{dolist}, @code{do-symbols} 833* Iteration:: @code{cl-do}, @code{cl-dotimes}, @code{cl-dolist}, @code{cl-do-symbols}.
860* Loop Facility:: The Common Lisp @code{loop} macro 834* Loop Facility:: The Common Lisp @code{cl-loop} macro.
861* Multiple Values:: @code{values}, @code{multiple-value-bind}, etc. 835* Multiple Values:: @code{values}, @code{cl-multiple-value-bind}, etc.
862@end menu 836@end menu
863 837
864@node Assignment 838@node Assignment
865@section Assignment 839@section Assignment
866 840
867@noindent 841@noindent
868The @code{psetq} form is just like @code{setq}, except that multiple 842The @code{cl-psetq} form is just like @code{setq}, except that multiple
869assignments are done in parallel rather than sequentially. 843assignments are done in parallel rather than sequentially.
870 844
871@defspec psetq [symbol form]@dots{} 845@defspec cl-psetq [symbol form]@dots{}
872This special form (actually a macro) is used to assign to several 846This special form (actually a macro) is used to assign to several
873variables simultaneously. Given only one @var{symbol} and @var{form}, 847variables simultaneously. Given only one @var{symbol} and @var{form},
874it has the same effect as @code{setq}. Given several @var{symbol} 848it has the same effect as @code{setq}. Given several @var{symbol}
@@ -883,21 +857,22 @@ x
883y ; @r{@code{y} was computed after @code{x} was set.} 857y ; @r{@code{y} was computed after @code{x} was set.}
884 @result{} 15 858 @result{} 15
885(setq x 2 y 3) 859(setq x 2 y 3)
886(psetq x (+ x y) y (* x y)) 860(cl-psetq x (+ x y) y (* x y))
887x 861x
888 @result{} 5 862 @result{} 5
889y ; @r{@code{y} was computed before @code{x} was set.} 863y ; @r{@code{y} was computed before @code{x} was set.}
890 @result{} 6 864 @result{} 6
891@end example 865@end example
892 866
893The simplest use of @code{psetq} is @code{(psetq x y y x)}, which 867The simplest use of @code{cl-psetq} is @code{(cl-psetq x y y x)}, which
894exchanges the values of two variables. (The @code{rotatef} form 868exchanges the values of two variables. (The @code{cl-rotatef} form
895provides an even more convenient way to swap two variables; 869provides an even more convenient way to swap two variables;
896@pxref{Modify Macros}.) 870@pxref{Modify Macros}.)
897 871
898@code{psetq} always returns @code{nil}. 872@code{cl-psetq} always returns @code{nil}.
899@end defspec 873@end defspec
900 874
875@c FIXME now in gv.el.
901@node Generalized Variables 876@node Generalized Variables
902@section Generalized Variables 877@section Generalized Variables
903 878
@@ -922,9 +897,9 @@ Just as certain forms like @code{a[i]} can be lvalues in C, there
922is a set of forms that can be generalized variables in Lisp. 897is a set of forms that can be generalized variables in Lisp.
923 898
924@menu 899@menu
925* Basic Setf:: @code{setf} and place forms 900* Basic Setf:: @code{setf} and place forms.
926* Modify Macros:: @code{incf}, @code{push}, @code{rotatef}, @code{letf}, @code{callf}, etc. 901* Modify Macros:: @code{cl-incf}, @code{push}, @code{cl-rotatef}, @code{letf}, @code{cl-callf}, etc.
927* Customizing Setf:: @code{define-modify-macro}, @code{defsetf}, @code{define-setf-method} 902* Customizing Setf:: @code{define-modify-macro}, @code{defsetf}, @code{define-setf-method}.
928@end menu 903@end menu
929 904
930@node Basic Setf 905@node Basic Setf
@@ -1107,7 +1082,7 @@ that operate on generalized variables. Many are interesting and
1107useful even when the @var{place} is just a variable name. 1082useful even when the @var{place} is just a variable name.
1108 1083
1109@defspec psetf [place form]@dots{} 1084@defspec psetf [place form]@dots{}
1110This macro is to @code{setf} what @code{psetq} is to @code{setq}: 1085This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}:
1111When several @var{place}s and @var{form}s are involved, the 1086When several @var{place}s and @var{form}s are involved, the
1112assignments take place in parallel rather than sequentially. 1087assignments take place in parallel rather than sequentially.
1113Specifically, all subforms are evaluated from left to right, then 1088Specifically, all subforms are evaluated from left to right, then
@@ -1533,10 +1508,10 @@ analogous to Lisp's built-in @code{let} form.
1533are also related to variable bindings. 1508are also related to variable bindings.
1534 1509
1535@menu 1510@menu
1536* Dynamic Bindings:: The @code{progv} form 1511* Dynamic Bindings:: The @code{progv} form.
1537* Lexical Bindings:: @code{lexical-let} and lexical closures 1512* Lexical Bindings:: @code{lexical-let} and lexical closures.
1538* Function Bindings:: @code{flet} and @code{labels} 1513* Function Bindings:: @code{flet} and @code{labels}.
1539* Macro Bindings:: @code{macrolet} and @code{symbol-macrolet} 1514* Macro Bindings:: @code{macrolet} and @code{symbol-macrolet}.
1540@end menu 1515@end menu
1541 1516
1542@node Dynamic Bindings 1517@node Dynamic Bindings
@@ -1563,7 +1538,7 @@ are ignored.
1563@subsection Lexical Bindings 1538@subsection Lexical Bindings
1564 1539
1565@noindent 1540@noindent
1566The @dfn{CL} package defines the following macro which 1541The @code{CL} package defines the following macro which
1567more closely follows the Common Lisp @code{let} form: 1542more closely follows the Common Lisp @code{let} form:
1568 1543
1569@defspec lexical-let (bindings@dots{}) forms@dots{} 1544@defspec lexical-let (bindings@dots{}) forms@dots{}
@@ -1984,7 +1959,7 @@ looping constructs to complement Emacs Lisp's basic @code{while}
1984loop. 1959loop.
1985 1960
1986@defspec loop forms@dots{} 1961@defspec loop forms@dots{}
1987The @dfn{CL} package supports both the simple, old-style meaning of 1962The @code{CL} package supports both the simple, old-style meaning of
1988@code{loop} and the extremely powerful and flexible feature known as 1963@code{loop} and the extremely powerful and flexible feature known as
1989the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced 1964the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced
1990facility is discussed in the following section; @pxref{Loop Facility}. 1965facility is discussed in the following section; @pxref{Loop Facility}.
@@ -2026,7 +2001,7 @@ associated @var{init} value as if by a @code{let} form. Then, in
2026each iteration of the loop, the @var{end-test} is evaluated; if 2001each iteration of the loop, the @var{end-test} is evaluated; if
2027true, the loop is finished. Otherwise, the body @var{forms} are 2002true, the loop is finished. Otherwise, the body @var{forms} are
2028evaluated, then each @var{var} is set to the associated @var{step} 2003evaluated, then each @var{var} is set to the associated @var{step}
2029expression (as if by a @code{psetq} form) and the next iteration 2004expression (as if by a @code{cl-psetq} form) and the next iteration
2030begins. Once the @var{end-test} becomes true, the @var{result} 2005begins. Once the @var{end-test} becomes true, the @var{result}
2031forms are evaluated (with the @var{var}s still bound to their 2006forms are evaluated (with the @var{var}s still bound to their
2032values) to produce the result returned by @code{do}. 2007values) to produce the result returned by @code{do}.
@@ -2065,7 +2040,7 @@ the rest of the loop.
2065This is to @code{do} what @code{let*} is to @code{let}. In 2040This is to @code{do} what @code{let*} is to @code{let}. In
2066particular, the initial values are bound as if by @code{let*} 2041particular, the initial values are bound as if by @code{let*}
2067rather than @code{let}, and the steps are assigned as if by 2042rather than @code{let}, and the steps are assigned as if by
2068@code{setq} rather than @code{psetq}. 2043@code{setq} rather than @code{cl-psetq}.
2069 2044
2070Here is another way to write the above loop: 2045Here is another way to write the above loop:
2071 2046
@@ -2133,12 +2108,12 @@ construct called the ``Loop Facility'' or ``@code{loop} macro,''
2133with an easy-to-use but very powerful and expressive syntax. 2108with an easy-to-use but very powerful and expressive syntax.
2134 2109
2135@menu 2110@menu
2136* Loop Basics:: @code{loop} macro, basic clause structure 2111* Loop Basics:: @code{loop} macro, basic clause structure.
2137* Loop Examples:: Working examples of @code{loop} macro 2112* Loop Examples:: Working examples of @code{loop} macro.
2138* For Clauses:: Clauses introduced by @code{for} or @code{as} 2113* For Clauses:: Clauses introduced by @code{for} or @code{as}.
2139* Iteration Clauses:: @code{repeat}, @code{while}, @code{thereis}, etc. 2114* Iteration Clauses:: @code{repeat}, @code{while}, @code{thereis}, etc.
2140* Accumulation Clauses:: @code{collect}, @code{sum}, @code{maximize}, etc. 2115* Accumulation Clauses:: @code{collect}, @code{sum}, @code{maximize}, etc.
2141* Other Clauses:: @code{with}, @code{if}, @code{initially}, @code{finally} 2116* Other Clauses:: @code{with}, @code{if}, @code{initially}, @code{finally}.
2142@end menu 2117@end menu
2143 2118
2144@node Loop Basics 2119@node Loop Basics
@@ -2546,7 +2521,7 @@ If you include several @code{for} clauses in a row, they are
2546treated sequentially (as if by @code{let*} and @code{setq}). 2521treated sequentially (as if by @code{let*} and @code{setq}).
2547You can instead use the word @code{and} to link the clauses, 2522You can instead use the word @code{and} to link the clauses,
2548in which case they are processed in parallel (as if by @code{let} 2523in which case they are processed in parallel (as if by @code{let}
2549and @code{psetq}). 2524and @code{cl-psetq}).
2550 2525
2551@example 2526@example
2552(loop for x below 5 for y = nil then x collect (list x y)) 2527(loop for x below 5 for y = nil then x collect (list x y))
@@ -3177,8 +3152,8 @@ This package defines several symbol-related features that were
3177missing from Emacs Lisp. 3152missing from Emacs Lisp.
3178 3153
3179@menu 3154@menu
3180* Property Lists:: @code{get*}, @code{remprop}, @code{getf}, @code{remf} 3155* Property Lists:: @code{get*}, @code{remprop}, @code{getf}, @code{remf}.
3181* Creating Symbols:: @code{gensym}, @code{gentemp} 3156* Creating Symbols:: @code{gensym}, @code{gentemp}.
3182@end menu 3157@end menu
3183 3158
3184@node Property Lists 3159@node Property Lists
@@ -3321,8 +3296,8 @@ which were left out of Emacs Lisp.
3321@menu 3296@menu
3322* Predicates on Numbers:: @code{plusp}, @code{oddp}, @code{floatp-safe}, etc. 3297* Predicates on Numbers:: @code{plusp}, @code{oddp}, @code{floatp-safe}, etc.
3323* Numerical Functions:: @code{abs}, @code{floor*}, etc. 3298* Numerical Functions:: @code{abs}, @code{floor*}, etc.
3324* Random Numbers:: @code{random*}, @code{make-random-state} 3299* Random Numbers:: @code{random*}, @code{make-random-state}.
3325* Implementation Parameters:: @code{most-positive-float} 3300* Implementation Parameters:: @code{most-positive-float}.
3326@end menu 3301@end menu
3327 3302
3328@iftex 3303@iftex
@@ -3614,11 +3589,11 @@ Emacs Lisp includes a few of these, notably @code{elt} and
3614@code{length}; this package defines most of the rest. 3589@code{length}; this package defines most of the rest.
3615 3590
3616@menu 3591@menu
3617* Sequence Basics:: Arguments shared by all sequence functions 3592* Sequence Basics:: Arguments shared by all sequence functions.
3618* Mapping over Sequences:: @code{mapcar*}, @code{mapcan}, @code{map}, @code{every}, etc. 3593* Mapping over Sequences:: @code{mapcar*}, @code{mapcan}, @code{map}, @code{every}, etc.
3619* Sequence Functions:: @code{subseq}, @code{remove*}, @code{substitute}, etc. 3594* Sequence Functions:: @code{subseq}, @code{remove*}, @code{substitute}, etc.
3620* Searching Sequences:: @code{find}, @code{position}, @code{count}, @code{search}, etc. 3595* Searching Sequences:: @code{find}, @code{position}, @code{count}, @code{search}, etc.
3621* Sorting Sequences:: @code{sort*}, @code{stable-sort}, @code{merge} 3596* Sorting Sequences:: @code{sort*}, @code{stable-sort}, @code{merge}.
3622@end menu 3597@end menu
3623 3598
3624@node Sequence Basics 3599@node Sequence Basics
@@ -4101,7 +4076,7 @@ The functions described here operate on lists.
4101* List Functions:: @code{caddr}, @code{first}, @code{list*}, etc. 4076* List Functions:: @code{caddr}, @code{first}, @code{list*}, etc.
4102* Substitution of Expressions:: @code{subst}, @code{sublis}, etc. 4077* Substitution of Expressions:: @code{subst}, @code{sublis}, etc.
4103* Lists as Sets:: @code{member*}, @code{adjoin}, @code{union}, etc. 4078* Lists as Sets:: @code{member*}, @code{adjoin}, @code{union}, etc.
4104* Association Lists:: @code{assoc*}, @code{rassoc*}, @code{acons}, @code{pairlis} 4079* Association Lists:: @code{assoc*}, @code{rassoc*}, @code{acons}, @code{pairlis}.
4105@end menu 4080@end menu
4106 4081
4107@node List Functions 4082@node List Functions
@@ -5045,7 +5020,7 @@ Lisp.
5045@appendixsec The @code{cl-compat} package 5020@appendixsec The @code{cl-compat} package
5046 5021
5047@noindent 5022@noindent
5048The @dfn{CL} package includes emulations of some features of the 5023The @code{CL} package includes emulations of some features of the
5049old @file{cl.el}, in the form of a compatibility package 5024old @file{cl.el}, in the form of a compatibility package
5050@code{cl-compat}. This file is obsolete and may be removed in future, 5025@code{cl-compat}. This file is obsolete and may be removed in future,
5051so it should not be used in new code. 5026so it should not be used in new code.
@@ -5066,7 +5041,7 @@ best fix is to change to use @code{setf} properly.
5066 5041
5067The @code{cl-compat} file defines the keyword functions 5042The @code{cl-compat} file defines the keyword functions
5068@code{keywordp}, @code{keyword-of}, and @code{defkeyword}, 5043@code{keywordp}, @code{keyword-of}, and @code{defkeyword},
5069which are not defined by the new @dfn{CL} package because the 5044which are not defined by the new @code{CL} package because the
5070use of keywords as data is discouraged. 5045use of keywords as data is discouraged.
5071 5046
5072The @code{build-klist} mechanism for parsing keyword arguments 5047The @code{build-klist} mechanism for parsing keyword arguments