diff options
Diffstat (limited to 'doc/misc')
| -rw-r--r-- | doc/misc/ChangeLog | 21 | ||||
| -rw-r--r-- | doc/misc/cl.texi | 327 |
2 files changed, 101 insertions, 247 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index 76859e09d42..ec46ab5eb05 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -1,5 +1,26 @@ | |||
| 1 | 2012-10-25 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * cl.texi: Don't mess with the TeX section number counter. | ||
| 4 | Use Texinfo recommended convention for quotes+punctuation. | ||
| 5 | (Overview, Sequence Functions): Rephrase for better line-breaking. | ||
| 6 | (Time of Evaluation, Type Predicates, Modify Macros, Function Bindings) | ||
| 7 | (Macro Bindings, Conditionals, Iteration, Loop Basics) | ||
| 8 | (Random Numbers, Mapping over Sequences, Structures) | ||
| 9 | (Porting Common Lisp): Further updates for cl-lib namespace. | ||
| 10 | (Modify Macros, Declarations, Macro Bindings, Structures): | ||
| 11 | Break long lines in examples. | ||
| 12 | (Dynamic Bindings): Update for changed progv behavior. | ||
| 13 | (Loop Examples, Efficiency Concerns): Markup fixes. | ||
| 14 | (Structures): Remove TeX margin change. | ||
| 15 | (Declarations): Fix typos. | ||
| 16 | |||
| 1 | 2012-10-24 Glenn Morris <rgm@gnu.org> | 17 | 2012-10-24 Glenn Morris <rgm@gnu.org> |
| 2 | 18 | ||
| 19 | * cl.texi (Overview, Multiple Values, Creating Symbols) | ||
| 20 | (Numerical Functions): Say less/nothing about the original cl.el. | ||
| 21 | (Old CL Compatibility): Remove. | ||
| 22 | (Assertions): Remove ignore-errors (standard Elisp for some time). | ||
| 23 | |||
| 3 | * cl.texi (Basic Setf, Macros, Declarations, Symbols, Numbers) | 24 | * cl.texi (Basic Setf, Macros, Declarations, Symbols, Numbers) |
| 4 | (Sequences, Lists, Structures, Assertions, Efficiency Concerns) | 25 | (Sequences, Lists, Structures, Assertions, Efficiency Concerns) |
| 5 | (Efficiency Concerns, Efficiency Concerns) | 26 | (Efficiency Concerns, Efficiency Concerns) |
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index 5908e94be02..9200958a1b5 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi | |||
| @@ -65,11 +65,10 @@ developing GNU and promoting software freedom.'' | |||
| 65 | * Sequences:: Mapping, functions, searching, sorting. | 65 | * Sequences:: Mapping, functions, searching, sorting. |
| 66 | * Lists:: @code{cl-caddr}, @code{cl-sublis}, @code{cl-member}, @code{cl-assoc}, etc. | 66 | * Lists:: @code{cl-caddr}, @code{cl-sublis}, @code{cl-member}, @code{cl-assoc}, etc. |
| 67 | * Structures:: @code{cl-defstruct}. | 67 | * Structures:: @code{cl-defstruct}. |
| 68 | * Assertions:: @code{cl-check-type}, @code{cl-assert}, @code{ignore-errors}. | 68 | * Assertions:: @code{cl-check-type}, @code{cl-assert}. |
| 69 | 69 | ||
| 70 | * Efficiency Concerns:: Hints and techniques. | 70 | * Efficiency Concerns:: Hints and techniques. |
| 71 | * Common Lisp Compatibility:: All known differences with Steele. | 71 | * Common Lisp Compatibility:: All known differences with Steele. |
| 72 | * Old CL Compatibility:: All known differences with old cl.el. | ||
| 73 | * Porting Common Lisp:: Hints for porting Common Lisp code. | 72 | * Porting Common Lisp:: Hints for porting Common Lisp code. |
| 74 | 73 | ||
| 75 | * GNU Free Documentation License:: The license for this documentation. | 74 | * GNU Free Documentation License:: The license for this documentation. |
| @@ -116,19 +115,16 @@ features. | |||
| 116 | 115 | ||
| 117 | @end itemize | 116 | @end itemize |
| 118 | 117 | ||
| 119 | The package described here was originally written by Dave Gillespie, | 118 | This package was originally written by Dave Gillespie, |
| 120 | @file{daveg@@synaptics.com}, as a total rewrite of an earlier | 119 | @file{daveg@@synaptics.com}, as a total rewrite of an earlier 1986 |
| 121 | 1986 @file{cl.el} package by Cesar Quiroz. Most features of the | 120 | @file{cl.el} package by Cesar Quiroz. Care has been taken to ensure |
| 122 | Quiroz package were retained; any incompatibilities are | 121 | that each function is defined efficiently, concisely, and with minimal |
| 123 | noted in the descriptions below. Care has been taken in this | 122 | impact on the rest of the Emacs environment. Stefan Monnier added the |
| 124 | version to ensure that each function is defined efficiently, | 123 | file @file{cl-lib.el} and rationalized the namespace for Emacs 24.3. |
| 125 | concisely, and with minimal impact on the rest of the Emacs | ||
| 126 | environment. Stefan Monnier added the file @file{cl-lib.el} and | ||
| 127 | rationalized the namespace for Emacs 24.3. | ||
| 128 | 124 | ||
| 129 | @menu | 125 | @menu |
| 130 | * Usage:: How to use the CL package. | 126 | * Usage:: How to use the CL package. |
| 131 | * Organization:: The package's five component files. | 127 | * Organization:: The package's component files. |
| 132 | * Naming Conventions:: Notes on CL function names. | 128 | * Naming Conventions:: Notes on CL function names. |
| 133 | @end menu | 129 | @end menu |
| 134 | 130 | ||
| @@ -198,12 +194,9 @@ no such restriction on the use of @code{cl-lib}. New code should use | |||
| 198 | @code{cl-lib} rather than @code{cl}. @xref{Naming Conventions}. | 194 | @code{cl-lib} rather than @code{cl}. @xref{Naming Conventions}. |
| 199 | 195 | ||
| 200 | There is one more file, @file{cl-compat.el}, which defines some | 196 | There is one more file, @file{cl-compat.el}, which defines some |
| 201 | routines from the older CL package that are not otherwise | 197 | routines from the older Quiroz CL package that are not otherwise |
| 202 | present in the new package. This includes internal routines | 198 | present in the new package. This file is obsolete and should not be |
| 203 | like @code{setelt} and @code{zip-lists}, deprecated features | 199 | used in new code. |
| 204 | like @code{defkeyword}, and an emulation of the old-style | ||
| 205 | multiple-values feature. This file is obsolete and should not be used | ||
| 206 | in new code. @xref{Old CL Compatibility}. | ||
| 207 | 200 | ||
| 208 | @node Naming Conventions | 201 | @node Naming Conventions |
| 209 | @section Naming Conventions | 202 | @section Naming Conventions |
| @@ -260,10 +253,6 @@ and the @code{cl-eval-when} construct. | |||
| 260 | * Time of Evaluation:: The @code{cl-eval-when} construct. | 253 | * Time of Evaluation:: The @code{cl-eval-when} construct. |
| 261 | @end menu | 254 | @end menu |
| 262 | 255 | ||
| 263 | @iftex | ||
| 264 | @secno=1 | ||
| 265 | @end iftex | ||
| 266 | |||
| 267 | @node Argument Lists | 256 | @node Argument Lists |
| 268 | @section Argument Lists | 257 | @section Argument Lists |
| 269 | 258 | ||
| @@ -572,16 +561,16 @@ last four would have been equivalent to the corresponding @code{setq}s. | |||
| 572 | Note that @code{(cl-eval-when (load eval) @dots{})} is equivalent | 561 | Note that @code{(cl-eval-when (load eval) @dots{})} is equivalent |
| 573 | to @code{(progn @dots{})} in all contexts. The compiler treats | 562 | to @code{(progn @dots{})} in all contexts. The compiler treats |
| 574 | certain top-level forms, like @code{defmacro} (sort-of) and | 563 | certain top-level forms, like @code{defmacro} (sort-of) and |
| 575 | @code{require}, as if they were wrapped in @code{(eval-when | 564 | @code{require}, as if they were wrapped in @code{(cl-eval-when |
| 576 | (compile load eval) @dots{})}. | 565 | (compile load eval) @dots{})}. |
| 577 | @end defspec | 566 | @end defspec |
| 578 | 567 | ||
| 579 | Emacs includes two special forms related to @code{cl-eval-when}. | 568 | Emacs includes two special forms related to @code{cl-eval-when}. |
| 580 | One of these, @code{eval-when-compile}, is not quite equivalent to | 569 | One of these, @code{eval-when-compile}, is not quite equivalent to |
| 581 | any @code{eval-when} construct and is described below. | 570 | any @code{cl-eval-when} construct and is described below. |
| 582 | 571 | ||
| 583 | The other form, @code{(eval-and-compile @dots{})}, is exactly | 572 | The other form, @code{(eval-and-compile @dots{})}, is exactly |
| 584 | equivalent to @samp{(eval-when (compile load eval) @dots{})} and | 573 | equivalent to @samp{(cl-eval-when (compile load eval) @dots{})} and |
| 585 | so is not itself defined by this package. | 574 | so is not itself defined by this package. |
| 586 | 575 | ||
| 587 | @defspec eval-when-compile forms... | 576 | @defspec eval-when-compile forms... |
| @@ -653,10 +642,6 @@ facts are true or false. | |||
| 653 | @node Type Predicates | 642 | @node Type Predicates |
| 654 | @section Type Predicates | 643 | @section Type Predicates |
| 655 | 644 | ||
| 656 | @noindent | ||
| 657 | The @code{CL} package defines a version of the Common Lisp @code{typep} | ||
| 658 | predicate. | ||
| 659 | |||
| 660 | @defun cl-typep object type | 645 | @defun cl-typep object type |
| 661 | Check if @var{object} is of type @var{type}, where @var{type} is a | 646 | Check if @var{object} is of type @var{type}, where @var{type} is a |
| 662 | (quoted) type name of the sort used by Common Lisp. For example, | 647 | (quoted) type name of the sort used by Common Lisp. For example, |
| @@ -737,7 +722,7 @@ related to @code{cl-typep}. | |||
| 737 | @defun cl-coerce object type | 722 | @defun cl-coerce object type |
| 738 | This function attempts to convert @var{object} to the specified | 723 | This function attempts to convert @var{object} to the specified |
| 739 | @var{type}. If @var{object} is already of that type as determined by | 724 | @var{type}. If @var{object} is already of that type as determined by |
| 740 | @code{typep}, it is simply returned. Otherwise, certain types of | 725 | @code{cl-typep}, it is simply returned. Otherwise, certain types of |
| 741 | conversions will be made: If @var{type} is any sequence type | 726 | conversions will be made: If @var{type} is any sequence type |
| 742 | (@code{string}, @code{list}, etc.) then @var{object} will be | 727 | (@code{string}, @code{list}, etc.) then @var{object} will be |
| 743 | converted to that type if possible. If @var{type} is | 728 | converted to that type if possible. If @var{type} is |
| @@ -1109,7 +1094,8 @@ does, which means the above form is @emph{not} equivalent to the | |||
| 1109 | ``obvious'' expansion, | 1094 | ``obvious'' expansion, |
| 1110 | 1095 | ||
| 1111 | @example | 1096 | @example |
| 1112 | (setf (aref vec (cl-incf i)) (1+ (aref vec (cl-incf i)))) ; Wrong! | 1097 | (setf (aref vec (cl-incf i)) |
| 1098 | (1+ (aref vec (cl-incf i)))) ; wrong! | ||
| 1113 | @end example | 1099 | @end example |
| 1114 | 1100 | ||
| 1115 | @noindent | 1101 | @noindent |
| @@ -1134,6 +1120,7 @@ This macro decrements the number stored in @var{place} by one, or | |||
| 1134 | by @var{x} if specified. | 1120 | by @var{x} if specified. |
| 1135 | @end defspec | 1121 | @end defspec |
| 1136 | 1122 | ||
| 1123 | @c FIXME move to lispref, add generalized variables. | ||
| 1137 | @defspec pop place | 1124 | @defspec pop place |
| 1138 | This macro removes and returns the first element of the list stored | 1125 | This macro removes and returns the first element of the list stored |
| 1139 | in @var{place}. It is analogous to @code{(prog1 (car @var{place}) | 1126 | in @var{place}. It is analogous to @code{(prog1 (car @var{place}) |
| @@ -1141,17 +1128,18 @@ in @var{place}. It is analogous to @code{(prog1 (car @var{place}) | |||
| 1141 | to evaluate all subforms only once. | 1128 | to evaluate all subforms only once. |
| 1142 | @end defspec | 1129 | @end defspec |
| 1143 | 1130 | ||
| 1131 | @c FIXME move to lispref, add generalized variables. | ||
| 1144 | @defspec push x place | 1132 | @defspec push x place |
| 1145 | This macro inserts @var{x} at the front of the list stored in | 1133 | This macro inserts @var{x} at the front of the list stored in |
| 1146 | @var{place}. It is analogous to @code{(setf @var{place} (cons | 1134 | @var{place}. It is analogous to @code{(setf @var{place} (cons |
| 1147 | @var{x} @var{place}))}, except for evaluation of the subforms. | 1135 | @var{x} @var{place}))}, except for evaluation of the subforms. |
| 1148 | @end defspec | 1136 | @end defspec |
| 1149 | 1137 | ||
| 1150 | @defspec pushnew x place @t{&key :test :test-not :key} | 1138 | @defspec cl-pushnew x place @t{&key :test :test-not :key} |
| 1151 | This macro inserts @var{x} at the front of the list stored in | 1139 | This macro inserts @var{x} at the front of the list stored in |
| 1152 | @var{place}, but only if @var{x} was not @code{eql} to any | 1140 | @var{place}, but only if @var{x} was not @code{eql} to any |
| 1153 | existing element of the list. The optional keyword arguments | 1141 | existing element of the list. The optional keyword arguments |
| 1154 | are interpreted in the same way as for @code{adjoin}. | 1142 | are interpreted in the same way as for @code{cl-adjoin}. |
| 1155 | @xref{Lists as Sets}. | 1143 | @xref{Lists as Sets}. |
| 1156 | @end defspec | 1144 | @end defspec |
| 1157 | 1145 | ||
| @@ -1175,9 +1163,9 @@ except that the subforms of @var{a}, @var{b}, and @var{c} are actually | |||
| 1175 | evaluated only once each and in the apparent order. | 1163 | evaluated only once each and in the apparent order. |
| 1176 | @end defspec | 1164 | @end defspec |
| 1177 | 1165 | ||
| 1178 | @defspec rotatef place@dots{} | 1166 | @defspec cl-rotatef place@dots{} |
| 1179 | This macro rotates the @var{place}s left by one in circular fashion. | 1167 | This macro rotates the @var{place}s left by one in circular fashion. |
| 1180 | Thus, @code{(rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to | 1168 | Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to |
| 1181 | 1169 | ||
| 1182 | @example | 1170 | @example |
| 1183 | (psetf @var{a} @var{b} | 1171 | (psetf @var{a} @var{b} |
| @@ -1187,8 +1175,8 @@ Thus, @code{(rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to | |||
| 1187 | @end example | 1175 | @end example |
| 1188 | 1176 | ||
| 1189 | @noindent | 1177 | @noindent |
| 1190 | except for the evaluation of subforms. @code{rotatef} always | 1178 | except for the evaluation of subforms. @code{cl-rotatef} always |
| 1191 | returns @code{nil}. Note that @code{(rotatef @var{a} @var{b})} | 1179 | returns @code{nil}. Note that @code{(cl-rotatef @var{a} @var{b})} |
| 1192 | conveniently exchanges @var{a} and @var{b}. | 1180 | conveniently exchanges @var{a} and @var{b}. |
| 1193 | @end defspec | 1181 | @end defspec |
| 1194 | 1182 | ||
| @@ -1247,40 +1235,40 @@ If the symbol is not bound on entry, it is simply made unbound by | |||
| 1247 | @code{makunbound} or @code{fmakunbound} on exit. | 1235 | @code{makunbound} or @code{fmakunbound} on exit. |
| 1248 | @end defspec | 1236 | @end defspec |
| 1249 | 1237 | ||
| 1250 | @defspec letf* (bindings@dots{}) forms@dots{} | 1238 | @defspec cl-letf* (bindings@dots{}) forms@dots{} |
| 1251 | This macro is to @code{letf} what @code{let*} is to @code{let}: | 1239 | This macro is to @code{letf} what @code{let*} is to @code{let}: |
| 1252 | It does the bindings in sequential rather than parallel order. | 1240 | It does the bindings in sequential rather than parallel order. |
| 1253 | @end defspec | 1241 | @end defspec |
| 1254 | 1242 | ||
| 1255 | @defspec callf @var{function} @var{place} @var{args}@dots{} | 1243 | @defspec cl-callf @var{function} @var{place} @var{args}@dots{} |
| 1256 | This is the ``generic'' modify macro. It calls @var{function}, | 1244 | This is the ``generic'' modify macro. It calls @var{function}, |
| 1257 | which should be an unquoted function name, macro name, or lambda. | 1245 | which should be an unquoted function name, macro name, or lambda. |
| 1258 | It passes @var{place} and @var{args} as arguments, and assigns the | 1246 | It passes @var{place} and @var{args} as arguments, and assigns the |
| 1259 | result back to @var{place}. For example, @code{(cl-incf @var{place} | 1247 | result back to @var{place}. For example, @code{(cl-incf @var{place} |
| 1260 | @var{n})} is the same as @code{(callf + @var{place} @var{n})}. | 1248 | @var{n})} is the same as @code{(cl-callf + @var{place} @var{n})}. |
| 1261 | Some more examples: | 1249 | Some more examples: |
| 1262 | 1250 | ||
| 1263 | @example | 1251 | @example |
| 1264 | (callf abs my-number) | 1252 | (cl-callf abs my-number) |
| 1265 | (callf concat (buffer-name) "<" (int-to-string n) ">") | 1253 | (cl-callf concat (buffer-name) "<" (number-to-string n) ">") |
| 1266 | (callf union happy-people (list joe bob) :test 'same-person) | 1254 | (cl-callf cl-union happy-people (list joe bob) :test 'same-person) |
| 1267 | @end example | 1255 | @end example |
| 1268 | 1256 | ||
| 1269 | @xref{Customizing Setf}, for @code{define-modify-macro}, a way | 1257 | @xref{Customizing Setf}, for @code{define-modify-macro}, a way |
| 1270 | to create even more concise notations for modify macros. Note | 1258 | to create even more concise notations for modify macros. Note |
| 1271 | again that @code{callf} is an extension to standard Common Lisp. | 1259 | again that @code{cl-callf} is an extension to standard Common Lisp. |
| 1272 | @end defspec | 1260 | @end defspec |
| 1273 | 1261 | ||
| 1274 | @defspec callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{} | 1262 | @defspec cl-callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{} |
| 1275 | This macro is like @code{callf}, except that @var{place} is | 1263 | This macro is like @code{cl-callf}, except that @var{place} is |
| 1276 | the @emph{second} argument of @var{function} rather than the | 1264 | the @emph{second} argument of @var{function} rather than the |
| 1277 | first. For example, @code{(push @var{x} @var{place})} is | 1265 | first. For example, @code{(push @var{x} @var{place})} is |
| 1278 | equivalent to @code{(callf2 cons @var{x} @var{place})}. | 1266 | equivalent to @code{(cl-callf2 cons @var{x} @var{place})}. |
| 1279 | @end defspec | 1267 | @end defspec |
| 1280 | 1268 | ||
| 1281 | The @code{callf} and @code{callf2} macros serve as building | 1269 | The @code{cl-callf} and @code{cl-callf2} macros serve as building |
| 1282 | blocks for other macros like @code{cl-incf}, @code{pushnew}, and | 1270 | blocks for other macros like @code{cl-incf}, @code{cl-pushnew}, and |
| 1283 | @code{define-modify-macro}. The @code{letf} and @code{letf*} | 1271 | @code{define-modify-macro}. The @code{letf} and @code{cl-letf*} |
| 1284 | macros are used in the processing of symbol macros; | 1272 | macros are used in the processing of symbol macros; |
| 1285 | @pxref{Macro Bindings}. | 1273 | @pxref{Macro Bindings}. |
| 1286 | 1274 | ||
| @@ -1494,10 +1482,6 @@ or otherwise declared; in newer Common Lisps, this would not be | |||
| 1494 | an error since the function @code{(setf @var{func})} might be | 1482 | an error since the function @code{(setf @var{func})} might be |
| 1495 | defined later. | 1483 | defined later. |
| 1496 | 1484 | ||
| 1497 | @iftex | ||
| 1498 | @secno=4 | ||
| 1499 | @end iftex | ||
| 1500 | |||
| 1501 | @node Variable Bindings | 1485 | @node Variable Bindings |
| 1502 | @section Variable Bindings | 1486 | @section Variable Bindings |
| 1503 | 1487 | ||
| @@ -1530,7 +1514,7 @@ set of variables computed at run-time. The expressions | |||
| 1530 | of symbols and values, respectively. The symbols are bound to the | 1514 | of symbols and values, respectively. The symbols are bound to the |
| 1531 | corresponding values for the duration of the body @var{form}s. | 1515 | corresponding values for the duration of the body @var{form}s. |
| 1532 | If @var{values} is shorter than @var{symbols}, the last few symbols | 1516 | If @var{values} is shorter than @var{symbols}, the last few symbols |
| 1533 | are made unbound (as if by @code{makunbound}) inside the body. | 1517 | are bound to @code{nil}. |
| 1534 | If @var{symbols} is shorter than @var{values}, the excess values | 1518 | If @var{symbols} is shorter than @var{values}, the excess values |
| 1535 | are ignored. | 1519 | are ignored. |
| 1536 | @end defspec | 1520 | @end defspec |
| @@ -1661,7 +1645,7 @@ This form establishes @code{let}-style bindings on the function | |||
| 1661 | cells of symbols rather than on the value cells. Each @var{binding} | 1645 | cells of symbols rather than on the value cells. Each @var{binding} |
| 1662 | must be a list of the form @samp{(@var{name} @var{arglist} | 1646 | must be a list of the form @samp{(@var{name} @var{arglist} |
| 1663 | @var{forms}@dots{})}, which defines a function exactly as if | 1647 | @var{forms}@dots{})}, which defines a function exactly as if |
| 1664 | it were a @code{defun*} form. The function @var{name} is defined | 1648 | it were a @code{cl-defun} form. The function @var{name} is defined |
| 1665 | accordingly for the duration of the body of the @code{flet}; then | 1649 | accordingly for the duration of the body of the @code{flet}; then |
| 1666 | the old function definition, or lack thereof, is restored. | 1650 | the old function definition, or lack thereof, is restored. |
| 1667 | 1651 | ||
| @@ -1729,7 +1713,7 @@ function, or a use of its name quoted by @code{quote} or | |||
| 1729 | @subsection Macro Bindings | 1713 | @subsection Macro Bindings |
| 1730 | 1714 | ||
| 1731 | @noindent | 1715 | @noindent |
| 1732 | These forms create local macros and ``symbol macros.'' | 1716 | These forms create local macros and ``symbol macros''. |
| 1733 | 1717 | ||
| 1734 | @defspec cl-macrolet (bindings@dots{}) forms@dots{} | 1718 | @defspec cl-macrolet (bindings@dots{}) forms@dots{} |
| 1735 | This form is analogous to @code{flet}, but for macros instead of | 1719 | This form is analogous to @code{flet}, but for macros instead of |
| @@ -1765,7 +1749,7 @@ I.e., @code{(setq foo 4)} in the above would be equivalent to | |||
| 1765 | @code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) 4)}. | 1749 | @code{(setf foo 4)}, which in turn expands to @code{(setf (car bar) 4)}. |
| 1766 | 1750 | ||
| 1767 | Likewise, a @code{let} or @code{let*} binding a symbol macro is | 1751 | Likewise, a @code{let} or @code{let*} binding a symbol macro is |
| 1768 | treated like a @code{letf} or @code{letf*}. This differs from true | 1752 | treated like a @code{letf} or @code{cl-letf*}. This differs from true |
| 1769 | Common Lisp, where the rules of lexical scoping cause a @code{let} | 1753 | Common Lisp, where the rules of lexical scoping cause a @code{let} |
| 1770 | binding to shadow a @code{cl-symbol-macrolet} binding. In this package, | 1754 | binding to shadow a @code{cl-symbol-macrolet} binding. In this package, |
| 1771 | only @code{lexical-let} and @code{lexical-let*} will shadow a symbol | 1755 | only @code{lexical-let} and @code{lexical-let*} will shadow a symbol |
| @@ -1779,8 +1763,9 @@ expansion of another macro: | |||
| 1779 | (cl-defmacro my-dolist ((x list) &rest body) | 1763 | (cl-defmacro my-dolist ((x list) &rest body) |
| 1780 | (let ((var (gensym))) | 1764 | (let ((var (gensym))) |
| 1781 | (list 'cl-loop 'for var 'on list 'do | 1765 | (list 'cl-loop 'for var 'on list 'do |
| 1782 | (cl-list* 'cl-symbol-macrolet (list (list x (list 'car var))) | 1766 | (cl-list* 'cl-symbol-macrolet |
| 1783 | body)))) | 1767 | (list (list x (list 'car var))) |
| 1768 | body)))) | ||
| 1784 | 1769 | ||
| 1785 | (setq mylist '(1 2 3 4)) | 1770 | (setq mylist '(1 2 3 4)) |
| 1786 | (my-dolist (x mylist) (cl-incf x)) | 1771 | (my-dolist (x mylist) (cl-incf x)) |
| @@ -1834,7 +1819,7 @@ of the form | |||
| 1834 | where @var{keylist} is a list of key values. If there is exactly | 1819 | where @var{keylist} is a list of key values. If there is exactly |
| 1835 | one value, and it is not a cons cell or the symbol @code{nil} or | 1820 | one value, and it is not a cons cell or the symbol @code{nil} or |
| 1836 | @code{t}, then it can be used by itself as a @var{keylist} without | 1821 | @code{t}, then it can be used by itself as a @var{keylist} without |
| 1837 | being enclosed in a list. All key values in the @code{case} form | 1822 | being enclosed in a list. All key values in the @code{cl-case} form |
| 1838 | must be distinct. The final clauses may use @code{t} in place of | 1823 | must be distinct. The final clauses may use @code{t} in place of |
| 1839 | a @var{keylist} to indicate a default clause that should be taken | 1824 | a @var{keylist} to indicate a default clause that should be taken |
| 1840 | if none of the other clauses match. (The symbol @code{otherwise} | 1825 | if none of the other clauses match. (The symbol @code{otherwise} |
| @@ -2005,7 +1990,7 @@ evaluated, then each @var{var} is set to the associated @var{step} | |||
| 2005 | expression (as if by a @code{cl-psetq} form) and the next iteration | 1990 | expression (as if by a @code{cl-psetq} form) and the next iteration |
| 2006 | begins. Once the @var{end-test} becomes true, the @var{result} | 1991 | begins. Once the @var{end-test} becomes true, the @var{result} |
| 2007 | forms are evaluated (with the @var{var}s still bound to their | 1992 | forms are evaluated (with the @var{var}s still bound to their |
| 2008 | values) to produce the result returned by @code{do}. | 1993 | values) to produce the result returned by @code{cl-do}. |
| 2009 | 1994 | ||
| 2010 | The entire @code{cl-do} loop is enclosed in an implicit @code{nil} | 1995 | The entire @code{cl-do} loop is enclosed in an implicit @code{nil} |
| 2011 | block, so that you can use @code{(cl-return)} to break out of the | 1996 | block, so that you can use @code{(cl-return)} to break out of the |
| @@ -2013,7 +1998,7 @@ loop at any time. | |||
| 2013 | 1998 | ||
| 2014 | If there are no @var{result} forms, the loop returns @code{nil}. | 1999 | If there are no @var{result} forms, the loop returns @code{nil}. |
| 2015 | If a given @var{var} has no @var{step} form, it is bound to its | 2000 | If a given @var{var} has no @var{step} form, it is bound to its |
| 2016 | @var{init} value but not otherwise modified during the @code{do} | 2001 | @var{init} value but not otherwise modified during the @code{cl-do} |
| 2017 | loop (unless the code explicitly modifies it); this case is just | 2002 | loop (unless the code explicitly modifies it); this case is just |
| 2018 | a shorthand for putting a @code{(let ((@var{var} @var{init})) @dots{})} | 2003 | a shorthand for putting a @code{(let ((@var{var} @var{init})) @dots{})} |
| 2019 | around the loop. If @var{init} is also omitted it defaults to | 2004 | around the loop. If @var{init} is also omitted it defaults to |
| @@ -2105,7 +2090,7 @@ that they are either too simple and limited, such as Common Lisp's | |||
| 2105 | obscure, like Common Lisp's @code{do} loop. | 2090 | obscure, like Common Lisp's @code{do} loop. |
| 2106 | 2091 | ||
| 2107 | To remedy this, recent versions of Common Lisp have added a new | 2092 | To remedy this, recent versions of Common Lisp have added a new |
| 2108 | construct called the ``Loop Facility'' or ``@code{loop} macro,'' | 2093 | construct called the ``Loop Facility'' or ``@code{loop} macro'', |
| 2109 | with an easy-to-use but very powerful and expressive syntax. | 2094 | with an easy-to-use but very powerful and expressive syntax. |
| 2110 | 2095 | ||
| 2111 | @menu | 2096 | @menu |
| @@ -2167,7 +2152,7 @@ them to return a value by using an accumulation clause like | |||
| 2167 | @code{collect}, an end-test clause like @code{always}, or an | 2152 | @code{collect}, an end-test clause like @code{always}, or an |
| 2168 | explicit @code{return} clause to jump out of the implicit block. | 2153 | explicit @code{return} clause to jump out of the implicit block. |
| 2169 | (Because the loop body is enclosed in an implicit block, you can | 2154 | (Because the loop body is enclosed in an implicit block, you can |
| 2170 | also use regular Lisp @code{return} or @code{return-from} to | 2155 | also use regular Lisp @code{cl-return} or @code{cl-return-from} to |
| 2171 | break out of the loop.) | 2156 | break out of the loop.) |
| 2172 | @end defspec | 2157 | @end defspec |
| 2173 | 2158 | ||
| @@ -2191,7 +2176,7 @@ language. | |||
| 2191 | 2176 | ||
| 2192 | @noindent | 2177 | @noindent |
| 2193 | This loop iterates over all Emacs buffers, using the list | 2178 | This loop iterates over all Emacs buffers, using the list |
| 2194 | returned by @code{buffer-list}. For each buffer @code{buf}, | 2179 | returned by @code{buffer-list}. For each buffer @var{buf}, |
| 2195 | it calls @code{buffer-file-name} and collects the results into | 2180 | it calls @code{buffer-file-name} and collects the results into |
| 2196 | a list, which is then returned from the @code{cl-loop} construct. | 2181 | a list, which is then returned from the @code{cl-loop} construct. |
| 2197 | The result is a list of the file names of all the buffers in | 2182 | The result is a list of the file names of all the buffers in |
| @@ -2824,6 +2809,7 @@ Of course, @code{return} is generally used inside an @code{if} or | |||
| 2824 | the loop would never get to ``loop'' more than once. | 2809 | the loop would never get to ``loop'' more than once. |
| 2825 | 2810 | ||
| 2826 | The clause @samp{return @var{form}} is equivalent to | 2811 | The clause @samp{return @var{form}} is equivalent to |
| 2812 | @c FIXME cl-do, cl-return? | ||
| 2827 | @samp{do (return @var{form})} (or @code{return-from} if the loop | 2813 | @samp{do (return @var{form})} (or @code{return-from} if the loop |
| 2828 | was named). The @code{return} clause is implemented a bit more | 2814 | was named). The @code{return} clause is implemented a bit more |
| 2829 | efficiently, though. | 2815 | efficiently, though. |
| @@ -2875,13 +2861,6 @@ It then sets the @var{var}s to these respective values, as if by | |||
| 2875 | in @code{cl-multiple-value-bind}. | 2861 | in @code{cl-multiple-value-bind}. |
| 2876 | @end defspec | 2862 | @end defspec |
| 2877 | 2863 | ||
| 2878 | The older Quiroz package attempted a more faithful (but still | ||
| 2879 | imperfect) emulation of Common Lisp multiple values. The old | ||
| 2880 | method ``usually'' simulated true multiple values quite well, | ||
| 2881 | but under certain circumstances would leave spurious return | ||
| 2882 | values in memory where a later, unrelated @code{cl-multiple-value-bind} | ||
| 2883 | form would see them. | ||
| 2884 | |||
| 2885 | Since a perfect emulation is not feasible in Emacs Lisp, this | 2864 | Since a perfect emulation is not feasible in Emacs Lisp, this |
| 2886 | package opts to keep it as simple and predictable as possible. | 2865 | package opts to keep it as simple and predictable as possible. |
| 2887 | 2866 | ||
| @@ -3074,7 +3053,8 @@ and declare it inline all at once. | |||
| 3074 | 3053 | ||
| 3075 | @example | 3054 | @example |
| 3076 | (cl-declaim (inline foo bar)) | 3055 | (cl-declaim (inline foo bar)) |
| 3077 | (cl-eval-when (compile load eval) (cl-proclaim '(inline foo bar))) | 3056 | (cl-eval-when (compile load eval) |
| 3057 | (cl-proclaim '(inline foo bar))) | ||
| 3078 | (defsubst foo (...) ...) ; instead of defun | 3058 | (defsubst foo (...) ...) ; instead of defun |
| 3079 | @end example | 3059 | @end example |
| 3080 | 3060 | ||
| @@ -3104,16 +3084,15 @@ The word @code{optimize} is followed by any number of lists like | |||
| 3104 | @code{(speed 3)} or @code{(safety 2)}. Common Lisp defines several | 3084 | @code{(speed 3)} or @code{(safety 2)}. Common Lisp defines several |
| 3105 | optimization ``qualities''; this package ignores all but @code{speed} | 3085 | optimization ``qualities''; this package ignores all but @code{speed} |
| 3106 | and @code{safety}. The value of a quality should be an integer from | 3086 | and @code{safety}. The value of a quality should be an integer from |
| 3107 | 0 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important.'' | 3087 | 0 to 3, with 0 meaning ``unimportant'' and 3 meaning ``very important''. |
| 3108 | The default level for both qualities is 1. | 3088 | The default level for both qualities is 1. |
| 3109 | 3089 | ||
| 3110 | In this package, with the optimizing compiler, the | 3090 | In this package, with the optimizing compiler, the |
| 3111 | @c FIXME does not exist? | 3091 | @code{speed} quality is tied to the @code{byte-optimize} |
| 3112 | @code{speed} quality is tied to the @code{byte-compile-optimize} | ||
| 3113 | flag, which is set to @code{nil} for @code{(speed 0)} and to | 3092 | flag, which is set to @code{nil} for @code{(speed 0)} and to |
| 3114 | @code{t} for higher settings; and the @code{safety} quality is | 3093 | @code{t} for higher settings; and the @code{safety} quality is |
| 3115 | tied to the @code{byte-compile-delete-errors} flag, which is | 3094 | tied to the @code{byte-compile-delete-errors} flag, which is |
| 3116 | set to @code{t} for @code{(safety 3)} and to @code{nil} for all | 3095 | set to @code{nil} for @code{(safety 3)} and to @code{t} for all |
| 3117 | lower settings. (The latter flag controls whether the compiler | 3096 | lower settings. (The latter flag controls whether the compiler |
| 3118 | is allowed to optimize out code whose only side-effect could | 3097 | is allowed to optimize out code whose only side-effect could |
| 3119 | be to signal an error, e.g., rewriting @code{(progn foo bar)} to | 3098 | be to signal an error, e.g., rewriting @code{(progn foo bar)} to |
| @@ -3138,7 +3117,7 @@ automatically be unset after the enclosing form is done.) | |||
| 3138 | This declaration controls what sorts of warnings are generated | 3117 | This declaration controls what sorts of warnings are generated |
| 3139 | by the byte compiler. Again, only the optimizing compiler | 3118 | by the byte compiler. Again, only the optimizing compiler |
| 3140 | generates warnings. The word @code{warn} is followed by any | 3119 | generates warnings. The word @code{warn} is followed by any |
| 3141 | number of ``warning qualities,'' similar in form to optimization | 3120 | number of ``warning qualities'', similar in form to optimization |
| 3142 | qualities. The currently supported warning types are | 3121 | qualities. The currently supported warning types are |
| 3143 | @code{redefine}, @code{callargs}, @code{unresolved}, and | 3122 | @code{redefine}, @code{callargs}, @code{unresolved}, and |
| 3144 | @code{free-vars}; in the current system, a value of 0 will | 3123 | @code{free-vars}; in the current system, a value of 0 will |
| @@ -3240,10 +3219,6 @@ whereas if it occurs later, this simply uses @code{setcdr} to splice | |||
| 3240 | out the property and value cells. | 3219 | out the property and value cells. |
| 3241 | @end defspec | 3220 | @end defspec |
| 3242 | 3221 | ||
| 3243 | @iftex | ||
| 3244 | @secno=2 | ||
| 3245 | @end iftex | ||
| 3246 | |||
| 3247 | @node Creating Symbols | 3222 | @node Creating Symbols |
| 3248 | @section Creating Symbols | 3223 | @section Creating Symbols |
| 3249 | 3224 | ||
| @@ -3282,12 +3257,11 @@ exists, the function keeps incrementing the counter and trying | |||
| 3282 | again until a new symbol is generated. | 3257 | again until a new symbol is generated. |
| 3283 | @end defun | 3258 | @end defun |
| 3284 | 3259 | ||
| 3285 | The Quiroz @file{cl.el} package also defined a @code{defkeyword} | 3260 | This package automatically creates all keywords that are called for by |
| 3286 | form for creating self-quoting keyword symbols. This package | 3261 | @code{&key} argument specifiers, and discourages the use of keywords |
| 3287 | automatically creates all keywords that are called for by | 3262 | as data unrelated to keyword arguments, so the related function |
| 3288 | @code{&key} argument specifiers, and discourages the use of | 3263 | @code{defkeyword} (to create self-quoting keyword symbols) is not |
| 3289 | keywords as data unrelated to keyword arguments, so the | 3264 | provided. |
| 3290 | @code{defkeyword} form has been discontinued. | ||
| 3291 | 3265 | ||
| 3292 | @node Numbers | 3266 | @node Numbers |
| 3293 | @chapter Numbers | 3267 | @chapter Numbers |
| @@ -3303,10 +3277,6 @@ which were left out of Emacs Lisp. | |||
| 3303 | * Implementation Parameters:: @code{cl-most-positive-float}. | 3277 | * Implementation Parameters:: @code{cl-most-positive-float}. |
| 3304 | @end menu | 3278 | @end menu |
| 3305 | 3279 | ||
| 3306 | @iftex | ||
| 3307 | @secno=1 | ||
| 3308 | @end iftex | ||
| 3309 | |||
| 3310 | @node Predicates on Numbers | 3280 | @node Predicates on Numbers |
| 3311 | @section Predicates on Numbers | 3281 | @section Predicates on Numbers |
| 3312 | 3282 | ||
| @@ -3340,10 +3310,6 @@ number. On systems that support floating-point, this is equivalent | |||
| 3340 | to @code{floatp}. On other systems, this always returns @code{nil}. | 3310 | to @code{floatp}. On other systems, this always returns @code{nil}. |
| 3341 | @end defun | 3311 | @end defun |
| 3342 | 3312 | ||
| 3343 | @iftex | ||
| 3344 | @secno=3 | ||
| 3345 | @end iftex | ||
| 3346 | |||
| 3347 | @node Numerical Functions | 3313 | @node Numerical Functions |
| 3348 | @section Numerical Functions | 3314 | @section Numerical Functions |
| 3349 | 3315 | ||
| @@ -3426,17 +3392,6 @@ This function returns the same value as the second return value | |||
| 3426 | of @code{cl-truncate}. | 3392 | of @code{cl-truncate}. |
| 3427 | @end defun | 3393 | @end defun |
| 3428 | 3394 | ||
| 3429 | @c FIXME this stuff is probably no longer of interest to anyone. | ||
| 3430 | These definitions are compatible with those in the Quiroz | ||
| 3431 | @file{cl.el} package, except that | ||
| 3432 | @c this package appends @samp{*} to certain function names to avoid | ||
| 3433 | @c conflicts with existing Emacs functions, and that | ||
| 3434 | the mechanism for returning multiple values is different. | ||
| 3435 | |||
| 3436 | @iftex | ||
| 3437 | @secno=8 | ||
| 3438 | @end iftex | ||
| 3439 | |||
| 3440 | @node Random Numbers | 3395 | @node Random Numbers |
| 3441 | @section Random Numbers | 3396 | @section Random Numbers |
| 3442 | 3397 | ||
| @@ -3454,7 +3409,7 @@ The @var{state} argument should be a @code{random-state} object | |||
| 3454 | which holds the state of the random number generator. The | 3409 | which holds the state of the random number generator. The |
| 3455 | function modifies this state object as a side effect. If | 3410 | function modifies this state object as a side effect. If |
| 3456 | @var{state} is omitted, it defaults to the variable | 3411 | @var{state} is omitted, it defaults to the variable |
| 3457 | @code{*random-state*}, which contains a pre-initialized | 3412 | @code{cl--random-state}, which contains a pre-initialized |
| 3458 | @code{random-state} object. | 3413 | @code{random-state} object. |
| 3459 | @end defun | 3414 | @end defun |
| 3460 | 3415 | ||
| @@ -3704,7 +3659,7 @@ just like @code{cl-mapcar}, but it returns a sequence of type | |||
| 3704 | @var{result-type} rather than a list. @var{result-type} must | 3659 | @var{result-type} rather than a list. @var{result-type} must |
| 3705 | be one of the following symbols: @code{vector}, @code{string}, | 3660 | be one of the following symbols: @code{vector}, @code{string}, |
| 3706 | @code{list} (in which case the effect is the same as for | 3661 | @code{list} (in which case the effect is the same as for |
| 3707 | @code{mapcar*}), or @code{nil} (in which case the results are | 3662 | @code{cl-mapcar}), or @code{nil} (in which case the results are |
| 3708 | thrown away and @code{cl-map} returns @code{nil}). | 3663 | thrown away and @code{cl-map} returns @code{nil}). |
| 3709 | @end defun | 3664 | @end defun |
| 3710 | 3665 | ||
| @@ -3935,9 +3890,10 @@ by returning a changed copy of the sequence. | |||
| 3935 | @findex cl-substitute-if-not | 3890 | @findex cl-substitute-if-not |
| 3936 | @findex cl-nsubstitute-if | 3891 | @findex cl-nsubstitute-if |
| 3937 | @findex cl-nsubstitute-if-not | 3892 | @findex cl-nsubstitute-if-not |
| 3938 | The @code{cl-substitute-if}, @code{cl-substitute-if-not}, @code{cl-nsubstitute-if}, | 3893 | The functions @code{cl-substitute-if}, @code{cl-substitute-if-not}, |
| 3939 | and @code{cl-nsubstitute-if-not} functions are defined similarly. For | 3894 | @code{cl-nsubstitute-if}, and @code{cl-nsubstitute-if-not} are defined |
| 3940 | these, a @var{predicate} is given in place of the @var{old} argument. | 3895 | similarly. For these, a @var{predicate} is given in place of the |
| 3896 | @var{old} argument. | ||
| 3941 | 3897 | ||
| 3942 | @node Searching Sequences | 3898 | @node Searching Sequences |
| 3943 | @section Searching Sequences | 3899 | @section Searching Sequences |
| @@ -4166,10 +4122,6 @@ specified test. The @code{:key} function, if specified, is | |||
| 4166 | applied to the elements of both trees. @xref{Sequences}. | 4122 | applied to the elements of both trees. @xref{Sequences}. |
| 4167 | @end defun | 4123 | @end defun |
| 4168 | 4124 | ||
| 4169 | @iftex | ||
| 4170 | @secno=3 | ||
| 4171 | @end iftex | ||
| 4172 | |||
| 4173 | @node Substitution of Expressions | 4125 | @node Substitution of Expressions |
| 4174 | @section Substitution of Expressions | 4126 | @section Substitution of Expressions |
| 4175 | 4127 | ||
| @@ -4405,7 +4357,7 @@ You can create a new @code{person} by calling @code{make-person}, | |||
| 4405 | which takes keyword arguments @code{:name}, @code{:age}, and | 4357 | which takes keyword arguments @code{:name}, @code{:age}, and |
| 4406 | @code{:sex} to specify the initial values of these slots in the | 4358 | @code{:sex} to specify the initial values of these slots in the |
| 4407 | new object. (Omitting any of these arguments leaves the corresponding | 4359 | new object. (Omitting any of these arguments leaves the corresponding |
| 4408 | slot ``undefined,'' according to the Common Lisp standard; in Emacs | 4360 | slot ``undefined'', according to the Common Lisp standard; in Emacs |
| 4409 | Lisp, such uninitialized slots are filled with @code{nil}.) | 4361 | Lisp, such uninitialized slots are filled with @code{nil}.) |
| 4410 | 4362 | ||
| 4411 | Given a @code{person}, @code{(copy-person @var{p})} makes a new | 4363 | Given a @code{person}, @code{(copy-person @var{p})} makes a new |
| @@ -4486,10 +4438,6 @@ enclosed in lists.) | |||
| 4486 | The following structure options are recognized. | 4438 | The following structure options are recognized. |
| 4487 | 4439 | ||
| 4488 | @table @code | 4440 | @table @code |
| 4489 | @iftex | ||
| 4490 | @itemmax=0 in | ||
| 4491 | @advance@leftskip-.5@tableindent | ||
| 4492 | @end iftex | ||
| 4493 | @item :conc-name | 4441 | @item :conc-name |
| 4494 | The argument is a symbol whose print name is used as the prefix for | 4442 | The argument is a symbol whose print name is used as the prefix for |
| 4495 | the names of slot accessor functions. The default is the name of | 4443 | the names of slot accessor functions. The default is the name of |
| @@ -4529,7 +4477,8 @@ option. | |||
| 4529 | (cl-defstruct | 4477 | (cl-defstruct |
| 4530 | (person | 4478 | (person |
| 4531 | (:constructor nil) ; no default constructor | 4479 | (:constructor nil) ; no default constructor |
| 4532 | (:constructor new-person (name sex &optional (age 0))) | 4480 | (:constructor new-person |
| 4481 | (name sex &optional (age 0))) | ||
| 4533 | (:constructor new-hound (&key (name "Rover") | 4482 | (:constructor new-hound (&key (name "Rover") |
| 4534 | (dog-years 0) | 4483 | (dog-years 0) |
| 4535 | &aux (age (* 7 dog-years)) | 4484 | &aux (age (* 7 dog-years)) |
| @@ -4540,7 +4489,7 @@ option. | |||
| 4540 | The first constructor here takes its arguments positionally rather | 4489 | The first constructor here takes its arguments positionally rather |
| 4541 | than by keyword. (In official Common Lisp terminology, constructors | 4490 | than by keyword. (In official Common Lisp terminology, constructors |
| 4542 | that work By Order of Arguments instead of by keyword are called | 4491 | that work By Order of Arguments instead of by keyword are called |
| 4543 | ``BOA constructors.'' No, I'm not making this up.) For example, | 4492 | ``BOA constructors''. No, I'm not making this up.) For example, |
| 4544 | @code{(new-person "Jane" 'female)} generates a person whose slots | 4493 | @code{(new-person "Jane" 'female)} generates a person whose slots |
| 4545 | are @code{"Jane"}, 0, and @code{female}, respectively. | 4494 | are @code{"Jane"}, 0, and @code{female}, respectively. |
| 4546 | 4495 | ||
| @@ -4566,7 +4515,7 @@ ever generated.) | |||
| 4566 | 4515 | ||
| 4567 | In true Common Lisp, @code{typep} is always able to recognize a | 4516 | In true Common Lisp, @code{typep} is always able to recognize a |
| 4568 | structure object even if @code{:predicate} was used. In this | 4517 | structure object even if @code{:predicate} was used. In this |
| 4569 | package, @code{typep} simply looks for a function called | 4518 | package, @code{cl-typep} simply looks for a function called |
| 4570 | @code{@var{typename}-p}, so it will work for structure types | 4519 | @code{@var{typename}-p}, so it will work for structure types |
| 4571 | only if they used the default predicate name. | 4520 | only if they used the default predicate name. |
| 4572 | 4521 | ||
| @@ -4752,18 +4701,6 @@ must be a @var{place} suitable for use by @code{setf}, because | |||
| 4752 | user to modify @var{place}. | 4701 | user to modify @var{place}. |
| 4753 | @end defspec | 4702 | @end defspec |
| 4754 | 4703 | ||
| 4755 | The following error-related macro is also defined: | ||
| 4756 | |||
| 4757 | @c FIXME standard for some time. | ||
| 4758 | @defspec ignore-errors forms@dots{} | ||
| 4759 | This executes @var{forms} exactly like a @code{progn}, except that | ||
| 4760 | errors are ignored during the @var{forms}. More precisely, if | ||
| 4761 | an error is signaled then @code{ignore-errors} immediately | ||
| 4762 | aborts execution of the @var{forms} and returns @code{nil}. | ||
| 4763 | If the @var{forms} complete successfully, @code{ignore-errors} | ||
| 4764 | returns the result of the last @var{form}. | ||
| 4765 | @end defspec | ||
| 4766 | |||
| 4767 | @node Efficiency Concerns | 4704 | @node Efficiency Concerns |
| 4768 | @appendix Efficiency Concerns | 4705 | @appendix Efficiency Concerns |
| 4769 | 4706 | ||
| @@ -4811,7 +4748,7 @@ This function takes a single Lisp form as an argument and inserts | |||
| 4811 | a nicely formatted copy of it in the current buffer (which must be | 4748 | a nicely formatted copy of it in the current buffer (which must be |
| 4812 | in Lisp mode so that indentation works properly). It also expands | 4749 | in Lisp mode so that indentation works properly). It also expands |
| 4813 | all Lisp macros which appear in the form. The easiest way to use | 4750 | all Lisp macros which appear in the form. The easiest way to use |
| 4814 | this function is to go to the @code{*scratch*} buffer and type, say, | 4751 | this function is to go to the @file{*scratch*} buffer and type, say, |
| 4815 | 4752 | ||
| 4816 | @example | 4753 | @example |
| 4817 | (cl-prettyexpand '(loop for x below 10 collect x)) | 4754 | (cl-prettyexpand '(loop for x below 10 collect x)) |
| @@ -4971,110 +4908,6 @@ special, distinct type. Also, the @code{:type} slot option is ignored. | |||
| 4971 | 4908 | ||
| 4972 | The second argument of @code{cl-check-type} is treated differently. | 4909 | The second argument of @code{cl-check-type} is treated differently. |
| 4973 | 4910 | ||
| 4974 | @c FIXME Time to remove this? | ||
| 4975 | @node Old CL Compatibility | ||
| 4976 | @appendix Old CL Compatibility | ||
| 4977 | |||
| 4978 | @noindent | ||
| 4979 | Following is a list of all known incompatibilities between this package | ||
| 4980 | and the older Quiroz @file{cl.el} package. | ||
| 4981 | |||
| 4982 | This package's emulation of multiple return values in functions is | ||
| 4983 | incompatible with that of the older package. That package attempted | ||
| 4984 | to come as close as possible to true Common Lisp multiple return | ||
| 4985 | values; unfortunately, it could not be 100% reliable and so was prone | ||
| 4986 | to occasional surprises if used freely. This package uses a simpler | ||
| 4987 | method, namely replacing multiple values with lists of values, which | ||
| 4988 | is more predictable though more noticeably different from Common Lisp. | ||
| 4989 | |||
| 4990 | The @code{defkeyword} form and @code{keywordp} function are not | ||
| 4991 | implemented in this package. | ||
| 4992 | |||
| 4993 | @ignore | ||
| 4994 | The @code{member}, @code{floor}, @code{ceiling}, @code{truncate}, | ||
| 4995 | @code{round}, @code{mod}, and @code{rem} functions are suffixed | ||
| 4996 | by @samp{*} in this package to avoid collision with existing | ||
| 4997 | functions in Emacs. The older package simply | ||
| 4998 | redefined these functions, overwriting the built-in meanings and | ||
| 4999 | causing serious portability problems. (Some more | ||
| 5000 | recent versions of the Quiroz package changed the names to | ||
| 5001 | @code{cl-member}, etc.; this package defines the latter names as | ||
| 5002 | aliases for @code{member*}, etc.) | ||
| 5003 | @end ignore | ||
| 5004 | |||
| 5005 | Certain functions in the old package which were buggy or inconsistent | ||
| 5006 | with the Common Lisp standard are incompatible with the conforming | ||
| 5007 | versions in this package. For example, @code{eql} and @code{member} | ||
| 5008 | were synonyms for @code{eq} and @code{memq} in that package, @code{setf} | ||
| 5009 | failed to preserve correct order of evaluation of its arguments, etc. | ||
| 5010 | |||
| 5011 | Finally, unlike the older package, this package is careful to | ||
| 5012 | prefix all of its internal names with @code{cl--}. Except for a | ||
| 5013 | few functions which are explicitly defined as additional features | ||
| 5014 | (such as @code{cl-floatp-safe} and @code{letf}), this package does not | ||
| 5015 | export any non-@samp{cl-} symbols which are not also part of Common | ||
| 5016 | Lisp. | ||
| 5017 | |||
| 5018 | @ifinfo | ||
| 5019 | @example | ||
| 5020 | |||
| 5021 | @end example | ||
| 5022 | @end ifinfo | ||
| 5023 | @appendixsec The @code{cl-compat} package | ||
| 5024 | |||
| 5025 | @noindent | ||
| 5026 | The @code{CL} package includes emulations of some features of the | ||
| 5027 | old @file{cl.el}, in the form of a compatibility package | ||
| 5028 | @code{cl-compat}. This file is obsolete and may be removed in future, | ||
| 5029 | so it should not be used in new code. | ||
| 5030 | |||
| 5031 | The old package defined a number of internal routines without | ||
| 5032 | @code{cl-} prefixes or other annotations. Call to these routines | ||
| 5033 | may have crept into existing Lisp code. @code{cl-compat} | ||
| 5034 | provides emulations of the following internal routines: | ||
| 5035 | @code{pair-with-newsyms}, @code{zip-lists}, @code{unzip-lists}, | ||
| 5036 | @code{reassemble-arglists}, @code{duplicate-symbols-p}, | ||
| 5037 | @code{safe-idiv}. | ||
| 5038 | |||
| 5039 | Some @code{setf} forms translated into calls to internal | ||
| 5040 | functions that user code might call directly. The functions | ||
| 5041 | @code{setnth}, @code{setnthcdr}, and @code{setelt} fall in | ||
| 5042 | this category; they are defined by @code{cl-compat}, but the | ||
| 5043 | best fix is to change to use @code{setf} properly. | ||
| 5044 | |||
| 5045 | The @code{cl-compat} file defines the keyword functions | ||
| 5046 | @code{keywordp}, @code{keyword-of}, and @code{defkeyword}, | ||
| 5047 | which are not defined by the new @code{CL} package because the | ||
| 5048 | use of keywords as data is discouraged. | ||
| 5049 | |||
| 5050 | The @code{build-klist} mechanism for parsing keyword arguments | ||
| 5051 | is emulated by @code{cl-compat}; the @code{with-keyword-args} | ||
| 5052 | macro is not, however, and in any case it's best to change to | ||
| 5053 | use the more natural keyword argument processing offered by | ||
| 5054 | @code{defun*}. | ||
| 5055 | |||
| 5056 | Multiple return values are treated differently by the two | ||
| 5057 | Common Lisp packages. The old package's method was more | ||
| 5058 | compatible with true Common Lisp, though it used heuristics | ||
| 5059 | that caused it to report spurious multiple return values in | ||
| 5060 | certain cases. The @code{cl-compat} package defines a set | ||
| 5061 | of multiple-value macros that are compatible with the old | ||
| 5062 | CL package; again, they are heuristic in nature, but they | ||
| 5063 | are guaranteed to work in any case where the old package's | ||
| 5064 | macros worked. To avoid name collision with the ``official'' | ||
| 5065 | multiple-value facilities, the ones in @code{cl-compat} have | ||
| 5066 | capitalized names: @code{Values}, @code{Values-list}, | ||
| 5067 | @code{Multiple-value-bind}, etc. | ||
| 5068 | |||
| 5069 | The functions @code{cl-floor}, @code{cl-ceiling}, @code{cl-truncate}, | ||
| 5070 | and @code{cl-round} are defined by @code{cl-compat} to use the | ||
| 5071 | old-style multiple-value mechanism, just as they did in the old | ||
| 5072 | package. The newer @code{floor*} and friends return their two | ||
| 5073 | results in a list rather than as multiple values. Note that | ||
| 5074 | older versions of the old package used the unadorned names | ||
| 5075 | @code{floor}, @code{ceiling}, etc.; @code{cl-compat} cannot use | ||
| 5076 | these names because they conflict with Emacs built-ins. | ||
| 5077 | |||
| 5078 | @node Porting Common Lisp | 4911 | @node Porting Common Lisp |
| 5079 | @appendix Porting Common Lisp | 4912 | @appendix Porting Common Lisp |
| 5080 | 4913 | ||
| @@ -5135,8 +4968,8 @@ in @code{map-odd-elements} by the time the @code{(+ a x)} function | |||
| 5135 | is called. | 4968 | is called. |
| 5136 | 4969 | ||
| 5137 | (This package avoids such problems in its own mapping functions | 4970 | (This package avoids such problems in its own mapping functions |
| 5138 | by using names like @code{cl-x} instead of @code{x} internally; | 4971 | by using names like @code{cl--x} instead of @code{x} internally; |
| 5139 | as long as you don't use the @code{cl-} prefix for your own | 4972 | as long as you don't use this prefix for your own |
| 5140 | variables no collision can occur.) | 4973 | variables no collision can occur.) |
| 5141 | 4974 | ||
| 5142 | @xref{Lexical Bindings}, for a description of the @code{lexical-let} | 4975 | @xref{Lexical Bindings}, for a description of the @code{lexical-let} |
| @@ -5181,7 +5014,7 @@ Lisp, they are totally distinct in Emacs Lisp. Common Lisp | |||
| 5181 | programs which refer to a symbol by the full name sometimes | 5014 | programs which refer to a symbol by the full name sometimes |
| 5182 | and the short name other times will not port cleanly to Emacs. | 5015 | and the short name other times will not port cleanly to Emacs. |
| 5183 | 5016 | ||
| 5184 | Emacs Lisp does have a concept of ``obarrays,'' which are | 5017 | Emacs Lisp does have a concept of ``obarrays'', which are |
| 5185 | package-like collections of symbols, but this feature is not | 5018 | package-like collections of symbols, but this feature is not |
| 5186 | strong enough to be used as a true package mechanism. | 5019 | strong enough to be used as a true package mechanism. |
| 5187 | 5020 | ||
| @@ -5201,10 +5034,10 @@ codes provide such features as paragraph filling, case | |||
| 5201 | conversion, and even loops and conditionals. | 5034 | conversion, and even loops and conditionals. |
| 5202 | 5035 | ||
| 5203 | While it would have been possible to implement most of Common | 5036 | While it would have been possible to implement most of Common |
| 5204 | Lisp @code{format} in this package (under the name @code{format*}, | 5037 | Lisp @code{format} in this package (under the name @code{cl-format}, |
| 5205 | of course), it was not deemed worthwhile. It would have required | 5038 | of course), it was not deemed worthwhile. It would have required |
| 5206 | a huge amount of code to implement even a decent subset of | 5039 | a huge amount of code to implement even a decent subset of |
| 5207 | @code{format*}, yet the functionality it would provide over | 5040 | @code{cl-format}, yet the functionality it would provide over |
| 5208 | Emacs Lisp's @code{format} would rarely be useful. | 5041 | Emacs Lisp's @code{format} would rarely be useful. |
| 5209 | 5042 | ||
| 5210 | @item | 5043 | @item |