diff options
| author | Glenn Morris | 2012-10-27 15:54:53 -0700 |
|---|---|---|
| committer | Glenn Morris | 2012-10-27 15:54:53 -0700 |
| commit | e11174254bab35ec88a8dfb483bd49104773d051 (patch) | |
| tree | 595e786318cefa19e434fd1aed246f4f5e3d351b /doc | |
| parent | 5887564d5b5c90a1bc2ff7c0a3412cb6f765d03e (diff) | |
| download | emacs-e11174254bab35ec88a8dfb483bd49104773d051.tar.gz emacs-e11174254bab35ec88a8dfb483bd49104773d051.zip | |
* doc/misc/cl.texi: Use defmac for macros rather than defspec.
(Efficiency Concerns): Related copyedit.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/ChangeLog | 3 | ||||
| -rw-r--r-- | doc/misc/cl.texi | 238 |
2 files changed, 121 insertions, 120 deletions
diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index d447b0ca1ff..24d8f1cee25 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2012-10-27 Glenn Morris <rgm@gnu.org> | 1 | 2012-10-27 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * cl.texi: Use defmac for macros rather than defspec. | ||
| 4 | (Efficiency Concerns): Related copyedit. | ||
| 5 | |||
| 3 | * cl.texi (Control Structure): Update for setf now being in core. | 6 | * cl.texi (Control Structure): Update for setf now being in core. |
| 4 | (Setf Extensions): Rename from Basic Setf. Move much of the | 7 | (Setf Extensions): Rename from Basic Setf. Move much of the |
| 5 | former content to lispref/variables.texi. | 8 | former content to lispref/variables.texi. |
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index aba3f244012..09386e2c0c7 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi | |||
| @@ -268,14 +268,14 @@ this package to implement Common Lisp argument lists seamlessly. | |||
| 268 | Instead, this package defines alternates for several Lisp forms | 268 | Instead, this package defines alternates for several Lisp forms |
| 269 | which you must use if you need Common Lisp argument lists. | 269 | which you must use if you need Common Lisp argument lists. |
| 270 | 270 | ||
| 271 | @defspec cl-defun name arglist body... | 271 | @defmac cl-defun name arglist body... |
| 272 | This form is identical to the regular @code{defun} form, except | 272 | This form is identical to the regular @code{defun} form, except |
| 273 | that @var{arglist} is allowed to be a full Common Lisp argument | 273 | that @var{arglist} is allowed to be a full Common Lisp argument |
| 274 | list. Also, the function body is enclosed in an implicit block | 274 | list. Also, the function body is enclosed in an implicit block |
| 275 | called @var{name}; @pxref{Blocks and Exits}. | 275 | called @var{name}; @pxref{Blocks and Exits}. |
| 276 | @end defspec | 276 | @end defmac |
| 277 | 277 | ||
| 278 | @defspec cl-defsubst name arglist body... | 278 | @defmac cl-defsubst name arglist body... |
| 279 | This is just like @code{cl-defun}, except that the function that | 279 | This is just like @code{cl-defun}, except that the function that |
| 280 | is defined is automatically proclaimed @code{inline}, i.e., | 280 | is defined is automatically proclaimed @code{inline}, i.e., |
| 281 | calls to it may be expanded into in-line code by the byte compiler. | 281 | calls to it may be expanded into in-line code by the byte compiler. |
| @@ -285,9 +285,9 @@ works in all versions of Emacs, and also generates somewhat more | |||
| 285 | efficient inline expansions. In particular, @code{cl-defsubst} | 285 | efficient inline expansions. In particular, @code{cl-defsubst} |
| 286 | arranges for the processing of keyword arguments, default values, | 286 | arranges for the processing of keyword arguments, default values, |
| 287 | etc., to be done at compile-time whenever possible. | 287 | etc., to be done at compile-time whenever possible. |
| 288 | @end defspec | 288 | @end defmac |
| 289 | 289 | ||
| 290 | @defspec cl-defmacro name arglist body... | 290 | @defmac cl-defmacro name arglist body... |
| 291 | This is identical to the regular @code{defmacro} form, | 291 | This is identical to the regular @code{defmacro} form, |
| 292 | except that @var{arglist} is allowed to be a full Common Lisp | 292 | except that @var{arglist} is allowed to be a full Common Lisp |
| 293 | argument list. The @code{&environment} keyword is supported as | 293 | argument list. The @code{&environment} keyword is supported as |
| @@ -296,13 +296,13 @@ within destructured lists (see below); top-level @code{&whole} | |||
| 296 | cannot be implemented with the current Emacs Lisp interpreter. | 296 | cannot be implemented with the current Emacs Lisp interpreter. |
| 297 | The macro expander body is enclosed in an implicit block called | 297 | The macro expander body is enclosed in an implicit block called |
| 298 | @var{name}. | 298 | @var{name}. |
| 299 | @end defspec | 299 | @end defmac |
| 300 | 300 | ||
| 301 | @defspec cl-function symbol-or-lambda | 301 | @defmac cl-function symbol-or-lambda |
| 302 | This is identical to the regular @code{function} form, | 302 | This is identical to the regular @code{function} form, |
| 303 | except that if the argument is a @code{lambda} form then that | 303 | except that if the argument is a @code{lambda} form then that |
| 304 | form may use a full Common Lisp argument list. | 304 | form may use a full Common Lisp argument list. |
| 305 | @end defspec | 305 | @end defmac |
| 306 | 306 | ||
| 307 | Also, all forms (such as @code{cl-flet} and @code{cl-labels}) defined | 307 | Also, all forms (such as @code{cl-flet} and @code{cl-labels}) defined |
| 308 | in this package that include @var{arglist}s in their syntax allow | 308 | in this package that include @var{arglist}s in their syntax allow |
| @@ -491,7 +491,7 @@ For example, the compiler effectively evaluates @code{defmacro} forms | |||
| 491 | at compile-time so that later parts of the file can refer to the | 491 | at compile-time so that later parts of the file can refer to the |
| 492 | macros that are defined. | 492 | macros that are defined. |
| 493 | 493 | ||
| 494 | @defspec cl-eval-when (situations...) forms... | 494 | @defmac cl-eval-when (situations...) forms... |
| 495 | This form controls when the body @var{forms} are evaluated. | 495 | This form controls when the body @var{forms} are evaluated. |
| 496 | The @var{situations} list may contain any set of the symbols | 496 | The @var{situations} list may contain any set of the symbols |
| 497 | @code{compile}, @code{load}, and @code{eval} (or their long-winded | 497 | @code{compile}, @code{load}, and @code{eval} (or their long-winded |
| @@ -563,7 +563,7 @@ to @code{(progn @dots{})} in all contexts. The compiler treats | |||
| 563 | certain top-level forms, like @code{defmacro} (sort-of) and | 563 | certain top-level forms, like @code{defmacro} (sort-of) and |
| 564 | @code{require}, as if they were wrapped in @code{(cl-eval-when | 564 | @code{require}, as if they were wrapped in @code{(cl-eval-when |
| 565 | (compile load eval) @dots{})}. | 565 | (compile load eval) @dots{})}. |
| 566 | @end defspec | 566 | @end defmac |
| 567 | 567 | ||
| 568 | Emacs includes two special forms related to @code{cl-eval-when}. | 568 | Emacs includes two special forms related to @code{cl-eval-when}. |
| 569 | 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 |
| @@ -573,7 +573,7 @@ The other form, @code{(eval-and-compile @dots{})}, is exactly | |||
| 573 | equivalent to @samp{(cl-eval-when (compile load eval) @dots{})} and | 573 | equivalent to @samp{(cl-eval-when (compile load eval) @dots{})} and |
| 574 | so is not itself defined by this package. | 574 | so is not itself defined by this package. |
| 575 | 575 | ||
| 576 | @defspec eval-when-compile forms... | 576 | @defmac eval-when-compile forms... |
| 577 | The @var{forms} are evaluated at compile-time; at execution time, | 577 | The @var{forms} are evaluated at compile-time; at execution time, |
| 578 | this form acts like a quoted constant of the resulting value. Used | 578 | this form acts like a quoted constant of the resulting value. Used |
| 579 | at top-level, @code{eval-when-compile} is just like @samp{eval-when | 579 | at top-level, @code{eval-when-compile} is just like @samp{eval-when |
| @@ -582,9 +582,9 @@ allows code to be evaluated once at compile-time for efficiency | |||
| 582 | or other reasons. | 582 | or other reasons. |
| 583 | 583 | ||
| 584 | This form is similar to the @samp{#.} syntax of true Common Lisp. | 584 | This form is similar to the @samp{#.} syntax of true Common Lisp. |
| 585 | @end defspec | 585 | @end defmac |
| 586 | 586 | ||
| 587 | @defspec cl-load-time-value form | 587 | @defmac cl-load-time-value form |
| 588 | The @var{form} is evaluated at load-time; at execution time, | 588 | The @var{form} is evaluated at load-time; at execution time, |
| 589 | this form acts like a quoted constant of the resulting value. | 589 | this form acts like a quoted constant of the resulting value. |
| 590 | 590 | ||
| @@ -625,7 +625,7 @@ Byte-compiled, the above defun will result in the following code | |||
| 625 | ", and loaded on: " | 625 | ", and loaded on: " |
| 626 | --temp--)) | 626 | --temp--)) |
| 627 | @end example | 627 | @end example |
| 628 | @end defspec | 628 | @end defmac |
| 629 | 629 | ||
| 630 | @node Predicates | 630 | @node Predicates |
| 631 | @chapter Predicates | 631 | @chapter Predicates |
| @@ -733,7 +733,7 @@ floats. In all other circumstances, @code{cl-coerce} signals an | |||
| 733 | error. | 733 | error. |
| 734 | @end defun | 734 | @end defun |
| 735 | 735 | ||
| 736 | @defspec cl-deftype name arglist forms... | 736 | @defmac cl-deftype name arglist forms... |
| 737 | This macro defines a new type called @var{name}. It is similar | 737 | This macro defines a new type called @var{name}. It is similar |
| 738 | to @code{defmacro} in many ways; when @var{name} is encountered | 738 | to @code{defmacro} in many ways; when @var{name} is encountered |
| 739 | as a type name, the body @var{forms} are evaluated and should | 739 | as a type name, the body @var{forms} are evaluated and should |
| @@ -761,7 +761,7 @@ unsigned-byte @equiv{} (integer 0 *) | |||
| 761 | The last example shows how the Common Lisp @code{unsigned-byte} | 761 | The last example shows how the Common Lisp @code{unsigned-byte} |
| 762 | type specifier could be implemented if desired; this package does | 762 | type specifier could be implemented if desired; this package does |
| 763 | not implement @code{unsigned-byte} by default. | 763 | not implement @code{unsigned-byte} by default. |
| 764 | @end defspec | 764 | @end defmac |
| 765 | 765 | ||
| 766 | The @code{cl-typecase} and @code{cl-check-type} macros also use type | 766 | The @code{cl-typecase} and @code{cl-check-type} macros also use type |
| 767 | names. @xref{Conditionals}. @xref{Assertions}. The @code{cl-map}, | 767 | names. @xref{Conditionals}. @xref{Assertions}. The @code{cl-map}, |
| @@ -826,7 +826,7 @@ constructs. | |||
| 826 | The @code{cl-psetq} form is just like @code{setq}, except that multiple | 826 | The @code{cl-psetq} form is just like @code{setq}, except that multiple |
| 827 | assignments are done in parallel rather than sequentially. | 827 | assignments are done in parallel rather than sequentially. |
| 828 | 828 | ||
| 829 | @defspec cl-psetq [symbol form]@dots{} | 829 | @defmac cl-psetq [symbol form]@dots{} |
| 830 | This special form (actually a macro) is used to assign to several | 830 | This special form (actually a macro) is used to assign to several |
| 831 | variables simultaneously. Given only one @var{symbol} and @var{form}, | 831 | variables simultaneously. Given only one @var{symbol} and @var{form}, |
| 832 | it has the same effect as @code{setq}. Given several @var{symbol} | 832 | it has the same effect as @code{setq}. Given several @var{symbol} |
| @@ -854,7 +854,7 @@ provides an even more convenient way to swap two variables; | |||
| 854 | @pxref{Modify Macros}.) | 854 | @pxref{Modify Macros}.) |
| 855 | 855 | ||
| 856 | @code{cl-psetq} always returns @code{nil}. | 856 | @code{cl-psetq} always returns @code{nil}. |
| 857 | @end defspec | 857 | @end defmac |
| 858 | 858 | ||
| 859 | @node Generalized Variables | 859 | @node Generalized Variables |
| 860 | @section Generalized Variables | 860 | @section Generalized Variables |
| @@ -1010,15 +1010,15 @@ This package defines a number of macros that operate on generalized | |||
| 1010 | variables. Many are interesting and useful even when the @var{place} | 1010 | variables. Many are interesting and useful even when the @var{place} |
| 1011 | is just a variable name. | 1011 | is just a variable name. |
| 1012 | 1012 | ||
| 1013 | @defspec cl-psetf [place form]@dots{} | 1013 | @defmac cl-psetf [place form]@dots{} |
| 1014 | This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}: | 1014 | This macro is to @code{setf} what @code{cl-psetq} is to @code{setq}: |
| 1015 | When several @var{place}s and @var{form}s are involved, the | 1015 | When several @var{place}s and @var{form}s are involved, the |
| 1016 | assignments take place in parallel rather than sequentially. | 1016 | assignments take place in parallel rather than sequentially. |
| 1017 | Specifically, all subforms are evaluated from left to right, then | 1017 | Specifically, all subforms are evaluated from left to right, then |
| 1018 | all the assignments are done (in an undefined order). | 1018 | all the assignments are done (in an undefined order). |
| 1019 | @end defspec | 1019 | @end defmac |
| 1020 | 1020 | ||
| 1021 | @defspec cl-incf place &optional x | 1021 | @defmac cl-incf place &optional x |
| 1022 | This macro increments the number stored in @var{place} by one, or | 1022 | This macro increments the number stored in @var{place} by one, or |
| 1023 | by @var{x} if specified. The incremented value is returned. For | 1023 | by @var{x} if specified. The incremented value is returned. For |
| 1024 | example, @code{(cl-incf i)} is equivalent to @code{(setq i (1+ i))}, and | 1024 | example, @code{(cl-incf i)} is equivalent to @code{(setq i (1+ i))}, and |
| @@ -1057,22 +1057,22 @@ the other generalized-variable macros. | |||
| 1057 | As a more Emacs-specific example of @code{cl-incf}, the expression | 1057 | As a more Emacs-specific example of @code{cl-incf}, the expression |
| 1058 | @code{(cl-incf (point) @var{n})} is essentially equivalent to | 1058 | @code{(cl-incf (point) @var{n})} is essentially equivalent to |
| 1059 | @code{(forward-char @var{n})}. | 1059 | @code{(forward-char @var{n})}. |
| 1060 | @end defspec | 1060 | @end defmac |
| 1061 | 1061 | ||
| 1062 | @defspec cl-decf place &optional x | 1062 | @defmac cl-decf place &optional x |
| 1063 | This macro decrements the number stored in @var{place} by one, or | 1063 | This macro decrements the number stored in @var{place} by one, or |
| 1064 | by @var{x} if specified. | 1064 | by @var{x} if specified. |
| 1065 | @end defspec | 1065 | @end defmac |
| 1066 | 1066 | ||
| 1067 | @defspec cl-pushnew x place @t{&key :test :test-not :key} | 1067 | @defmac cl-pushnew x place @t{&key :test :test-not :key} |
| 1068 | This macro inserts @var{x} at the front of the list stored in | 1068 | This macro inserts @var{x} at the front of the list stored in |
| 1069 | @var{place}, but only if @var{x} was not @code{eql} to any | 1069 | @var{place}, but only if @var{x} was not @code{eql} to any |
| 1070 | existing element of the list. The optional keyword arguments | 1070 | existing element of the list. The optional keyword arguments |
| 1071 | are interpreted in the same way as for @code{cl-adjoin}. | 1071 | are interpreted in the same way as for @code{cl-adjoin}. |
| 1072 | @xref{Lists as Sets}. | 1072 | @xref{Lists as Sets}. |
| 1073 | @end defspec | 1073 | @end defmac |
| 1074 | 1074 | ||
| 1075 | @defspec cl-shiftf place@dots{} newvalue | 1075 | @defmac cl-shiftf place@dots{} newvalue |
| 1076 | This macro shifts the @var{place}s left by one, shifting in the | 1076 | This macro shifts the @var{place}s left by one, shifting in the |
| 1077 | value of @var{newvalue} (which may be any Lisp expression, not just | 1077 | value of @var{newvalue} (which may be any Lisp expression, not just |
| 1078 | a generalized variable), and returning the value shifted out of | 1078 | a generalized variable), and returning the value shifted out of |
| @@ -1090,9 +1090,9 @@ the first @var{place}. Thus, @code{(cl-shiftf @var{a} @var{b} @var{c} | |||
| 1090 | @noindent | 1090 | @noindent |
| 1091 | except that the subforms of @var{a}, @var{b}, and @var{c} are actually | 1091 | except that the subforms of @var{a}, @var{b}, and @var{c} are actually |
| 1092 | evaluated only once each and in the apparent order. | 1092 | evaluated only once each and in the apparent order. |
| 1093 | @end defspec | 1093 | @end defmac |
| 1094 | 1094 | ||
| 1095 | @defspec cl-rotatef place@dots{} | 1095 | @defmac cl-rotatef place@dots{} |
| 1096 | This macro rotates the @var{place}s left by one in circular fashion. | 1096 | This macro rotates the @var{place}s left by one in circular fashion. |
| 1097 | Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to | 1097 | Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to |
| 1098 | 1098 | ||
| @@ -1107,12 +1107,12 @@ Thus, @code{(cl-rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to | |||
| 1107 | except for the evaluation of subforms. @code{cl-rotatef} always | 1107 | except for the evaluation of subforms. @code{cl-rotatef} always |
| 1108 | returns @code{nil}. Note that @code{(cl-rotatef @var{a} @var{b})} | 1108 | returns @code{nil}. Note that @code{(cl-rotatef @var{a} @var{b})} |
| 1109 | conveniently exchanges @var{a} and @var{b}. | 1109 | conveniently exchanges @var{a} and @var{b}. |
| 1110 | @end defspec | 1110 | @end defmac |
| 1111 | 1111 | ||
| 1112 | The following macros were invented for this package; they have no | 1112 | The following macros were invented for this package; they have no |
| 1113 | analogues in Common Lisp. | 1113 | analogues in Common Lisp. |
| 1114 | 1114 | ||
| 1115 | @defspec letf (bindings@dots{}) forms@dots{} | 1115 | @defmac letf (bindings@dots{}) forms@dots{} |
| 1116 | This macro is analogous to @code{let}, but for generalized variables | 1116 | This macro is analogous to @code{let}, but for generalized variables |
| 1117 | rather than just symbols. Each @var{binding} should be of the form | 1117 | rather than just symbols. Each @var{binding} should be of the form |
| 1118 | @code{(@var{place} @var{value})}; the original contents of the | 1118 | @code{(@var{place} @var{value})}; the original contents of the |
| @@ -1162,14 +1162,14 @@ entry to the @code{letf} form. The only exceptions are plain | |||
| 1162 | variables and calls to @code{symbol-value} and @code{symbol-function}. | 1162 | variables and calls to @code{symbol-value} and @code{symbol-function}. |
| 1163 | If the symbol is not bound on entry, it is simply made unbound by | 1163 | If the symbol is not bound on entry, it is simply made unbound by |
| 1164 | @code{makunbound} or @code{fmakunbound} on exit. | 1164 | @code{makunbound} or @code{fmakunbound} on exit. |
| 1165 | @end defspec | 1165 | @end defmac |
| 1166 | 1166 | ||
| 1167 | @defspec cl-letf* (bindings@dots{}) forms@dots{} | 1167 | @defmac cl-letf* (bindings@dots{}) forms@dots{} |
| 1168 | This macro is to @code{letf} what @code{let*} is to @code{let}: | 1168 | This macro is to @code{letf} what @code{let*} is to @code{let}: |
| 1169 | It does the bindings in sequential rather than parallel order. | 1169 | It does the bindings in sequential rather than parallel order. |
| 1170 | @end defspec | 1170 | @end defmac |
| 1171 | 1171 | ||
| 1172 | @defspec cl-callf @var{function} @var{place} @var{args}@dots{} | 1172 | @defmac cl-callf @var{function} @var{place} @var{args}@dots{} |
| 1173 | This is the ``generic'' modify macro. It calls @var{function}, | 1173 | This is the ``generic'' modify macro. It calls @var{function}, |
| 1174 | which should be an unquoted function name, macro name, or lambda. | 1174 | which should be an unquoted function name, macro name, or lambda. |
| 1175 | It passes @var{place} and @var{args} as arguments, and assigns the | 1175 | It passes @var{place} and @var{args} as arguments, and assigns the |
| @@ -1186,14 +1186,14 @@ Some more examples: | |||
| 1186 | @xref{Customizing Setf}, for @code{define-modify-macro}, a way | 1186 | @xref{Customizing Setf}, for @code{define-modify-macro}, a way |
| 1187 | to create even more concise notations for modify macros. Note | 1187 | to create even more concise notations for modify macros. Note |
| 1188 | again that @code{cl-callf} is an extension to standard Common Lisp. | 1188 | again that @code{cl-callf} is an extension to standard Common Lisp. |
| 1189 | @end defspec | 1189 | @end defmac |
| 1190 | 1190 | ||
| 1191 | @defspec cl-callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{} | 1191 | @defmac cl-callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{} |
| 1192 | This macro is like @code{cl-callf}, except that @var{place} is | 1192 | This macro is like @code{cl-callf}, except that @var{place} is |
| 1193 | the @emph{second} argument of @var{function} rather than the | 1193 | the @emph{second} argument of @var{function} rather than the |
| 1194 | first. For example, @code{(push @var{x} @var{place})} is | 1194 | first. For example, @code{(push @var{x} @var{place})} is |
| 1195 | equivalent to @code{(cl-callf2 cons @var{x} @var{place})}. | 1195 | equivalent to @code{(cl-callf2 cons @var{x} @var{place})}. |
| 1196 | @end defspec | 1196 | @end defmac |
| 1197 | 1197 | ||
| 1198 | The @code{cl-callf} and @code{cl-callf2} macros serve as building | 1198 | The @code{cl-callf} and @code{cl-callf2} macros serve as building |
| 1199 | blocks for other macros like @code{cl-incf}, @code{cl-pushnew}, and | 1199 | blocks for other macros like @code{cl-incf}, @code{cl-pushnew}, and |
| @@ -1209,7 +1209,7 @@ Common Lisp defines three macros, @code{define-modify-macro}, | |||
| 1209 | @code{defsetf}, and @code{define-setf-method}, that allow the | 1209 | @code{defsetf}, and @code{define-setf-method}, that allow the |
| 1210 | user to extend generalized variables in various ways. | 1210 | user to extend generalized variables in various ways. |
| 1211 | 1211 | ||
| 1212 | @defspec define-modify-macro name arglist function [doc-string] | 1212 | @defmac define-modify-macro name arglist function [doc-string] |
| 1213 | This macro defines a ``read-modify-write'' macro similar to | 1213 | This macro defines a ``read-modify-write'' macro similar to |
| 1214 | @code{cl-incf} and @code{cl-decf}. The macro @var{name} is defined | 1214 | @code{cl-incf} and @code{cl-decf}. The macro @var{name} is defined |
| 1215 | to take a @var{place} argument followed by additional arguments | 1215 | to take a @var{place} argument followed by additional arguments |
| @@ -1249,9 +1249,9 @@ follow the pattern of @code{define-modify-macro}. For example, | |||
| 1249 | is completely irregular. You can define these macros ``by hand'' | 1249 | is completely irregular. You can define these macros ``by hand'' |
| 1250 | using @code{get-setf-method}, or consult the source | 1250 | using @code{get-setf-method}, or consult the source |
| 1251 | to see how to use the internal @code{setf} building blocks. | 1251 | to see how to use the internal @code{setf} building blocks. |
| 1252 | @end defspec | 1252 | @end defmac |
| 1253 | 1253 | ||
| 1254 | @defspec defsetf access-fn update-fn | 1254 | @defmac defsetf access-fn update-fn |
| 1255 | This is the simpler of two @code{defsetf} forms. Where | 1255 | This is the simpler of two @code{defsetf} forms. Where |
| 1256 | @var{access-fn} is the name of a function which accesses a place, | 1256 | @var{access-fn} is the name of a function which accesses a place, |
| 1257 | this declares @var{update-fn} to be the corresponding store | 1257 | this declares @var{update-fn} to be the corresponding store |
| @@ -1294,9 +1294,9 @@ suite of setf methods, are: | |||
| 1294 | (defsetf symbol-value set) | 1294 | (defsetf symbol-value set) |
| 1295 | (defsetf buffer-name rename-buffer t) | 1295 | (defsetf buffer-name rename-buffer t) |
| 1296 | @end example | 1296 | @end example |
| 1297 | @end defspec | 1297 | @end defmac |
| 1298 | 1298 | ||
| 1299 | @defspec defsetf access-fn arglist (store-var) forms@dots{} | 1299 | @defmac defsetf access-fn arglist (store-var) forms@dots{} |
| 1300 | This is the second, more complex, form of @code{defsetf}. It is | 1300 | This is the second, more complex, form of @code{defsetf}. It is |
| 1301 | rather like @code{defmacro} except for the additional @var{store-var} | 1301 | rather like @code{defmacro} except for the additional @var{store-var} |
| 1302 | argument. The @var{forms} should return a Lisp form which stores | 1302 | argument. The @var{forms} should return a Lisp form which stores |
| @@ -1325,9 +1325,9 @@ Another example drawn from the standard package: | |||
| 1325 | (defsetf nth (n x) (store) | 1325 | (defsetf nth (n x) (store) |
| 1326 | (list 'setcar (list 'nthcdr n x) store)) | 1326 | (list 'setcar (list 'nthcdr n x) store)) |
| 1327 | @end example | 1327 | @end example |
| 1328 | @end defspec | 1328 | @end defmac |
| 1329 | 1329 | ||
| 1330 | @defspec define-setf-method access-fn arglist forms@dots{} | 1330 | @defmac define-setf-method access-fn arglist forms@dots{} |
| 1331 | This is the most general way to create new place forms. When | 1331 | This is the most general way to create new place forms. When |
| 1332 | a @code{setf} to @var{access-fn} with arguments described by | 1332 | a @code{setf} to @var{access-fn} with arguments described by |
| 1333 | @var{arglist} is expanded, the @var{forms} are evaluated and | 1333 | @var{arglist} is expanded, the @var{forms} are evaluated and |
| @@ -1372,7 +1372,7 @@ by @code{cl-gensym}. Macros like @code{setf} and @code{cl-incf} which | |||
| 1372 | use this setf-method will optimize away most temporaries that | 1372 | use this setf-method will optimize away most temporaries that |
| 1373 | turn out to be unnecessary, so there is little reason for the | 1373 | turn out to be unnecessary, so there is little reason for the |
| 1374 | setf-method itself to optimize. | 1374 | setf-method itself to optimize. |
| 1375 | @end defspec | 1375 | @end defmac |
| 1376 | 1376 | ||
| 1377 | @defun get-setf-method place &optional env | 1377 | @defun get-setf-method place &optional env |
| 1378 | This function returns the setf-method for @var{place}, by | 1378 | This function returns the setf-method for @var{place}, by |
| @@ -1435,7 +1435,7 @@ The standard @code{let} form binds variables whose names are known | |||
| 1435 | at compile-time. The @code{cl-progv} form provides an easy way to | 1435 | at compile-time. The @code{cl-progv} form provides an easy way to |
| 1436 | bind variables whose names are computed at run-time. | 1436 | bind variables whose names are computed at run-time. |
| 1437 | 1437 | ||
| 1438 | @defspec cl-progv symbols values forms@dots{} | 1438 | @defmac cl-progv symbols values forms@dots{} |
| 1439 | This form establishes @code{let}-style variable bindings on a | 1439 | This form establishes @code{let}-style variable bindings on a |
| 1440 | set of variables computed at run-time. The expressions | 1440 | set of variables computed at run-time. The expressions |
| 1441 | @var{symbols} and @var{values} are evaluated, and must return lists | 1441 | @var{symbols} and @var{values} are evaluated, and must return lists |
| @@ -1445,7 +1445,7 @@ If @var{values} is shorter than @var{symbols}, the last few symbols | |||
| 1445 | are bound to @code{nil}. | 1445 | are bound to @code{nil}. |
| 1446 | If @var{symbols} is shorter than @var{values}, the excess values | 1446 | If @var{symbols} is shorter than @var{values}, the excess values |
| 1447 | are ignored. | 1447 | are ignored. |
| 1448 | @end defspec | 1448 | @end defmac |
| 1449 | 1449 | ||
| 1450 | @node Lexical Bindings | 1450 | @node Lexical Bindings |
| 1451 | @subsection Lexical Bindings | 1451 | @subsection Lexical Bindings |
| @@ -1454,7 +1454,7 @@ are ignored. | |||
| 1454 | The @code{CL} package defines the following macro which | 1454 | The @code{CL} package defines the following macro which |
| 1455 | more closely follows the Common Lisp @code{let} form: | 1455 | more closely follows the Common Lisp @code{let} form: |
| 1456 | 1456 | ||
| 1457 | @defspec lexical-let (bindings@dots{}) forms@dots{} | 1457 | @defmac lexical-let (bindings@dots{}) forms@dots{} |
| 1458 | This form is exactly like @code{let} except that the bindings it | 1458 | This form is exactly like @code{let} except that the bindings it |
| 1459 | establishes are purely lexical. Lexical bindings are similar to | 1459 | establishes are purely lexical. Lexical bindings are similar to |
| 1460 | local variables in a language like C: Only the code physically | 1460 | local variables in a language like C: Only the code physically |
| @@ -1554,12 +1554,12 @@ instance of the lexical variable. | |||
| 1554 | 1554 | ||
| 1555 | The @code{lexical-let} form is an extension to Common Lisp. In | 1555 | The @code{lexical-let} form is an extension to Common Lisp. In |
| 1556 | true Common Lisp, all bindings are lexical unless declared otherwise. | 1556 | true Common Lisp, all bindings are lexical unless declared otherwise. |
| 1557 | @end defspec | 1557 | @end defmac |
| 1558 | 1558 | ||
| 1559 | @defspec lexical-let* (bindings@dots{}) forms@dots{} | 1559 | @defmac lexical-let* (bindings@dots{}) forms@dots{} |
| 1560 | This form is just like @code{lexical-let}, except that the bindings | 1560 | This form is just like @code{lexical-let}, except that the bindings |
| 1561 | are made sequentially in the manner of @code{let*}. | 1561 | are made sequentially in the manner of @code{let*}. |
| 1562 | @end defspec | 1562 | @end defmac |
| 1563 | 1563 | ||
| 1564 | @node Function Bindings | 1564 | @node Function Bindings |
| 1565 | @subsection Function Bindings | 1565 | @subsection Function Bindings |
| @@ -1568,7 +1568,7 @@ are made sequentially in the manner of @code{let*}. | |||
| 1568 | These forms make @code{let}-like bindings to functions instead | 1568 | These forms make @code{let}-like bindings to functions instead |
| 1569 | of variables. | 1569 | of variables. |
| 1570 | 1570 | ||
| 1571 | @defspec flet (bindings@dots{}) forms@dots{} | 1571 | @defmac flet (bindings@dots{}) forms@dots{} |
| 1572 | This form establishes @code{let}-style bindings on the function | 1572 | This form establishes @code{let}-style bindings on the function |
| 1573 | cells of symbols rather than on the value cells. Each @var{binding} | 1573 | cells of symbols rather than on the value cells. Each @var{binding} |
| 1574 | must be a list of the form @samp{(@var{name} @var{arglist} | 1574 | must be a list of the form @samp{(@var{name} @var{arglist} |
| @@ -1612,9 +1612,9 @@ Functions defined by @code{flet} may use the full Common Lisp | |||
| 1612 | argument notation supported by @code{cl-defun}; also, the function | 1612 | argument notation supported by @code{cl-defun}; also, the function |
| 1613 | body is enclosed in an implicit block as if by @code{cl-defun}. | 1613 | body is enclosed in an implicit block as if by @code{cl-defun}. |
| 1614 | @xref{Program Structure}. | 1614 | @xref{Program Structure}. |
| 1615 | @end defspec | 1615 | @end defmac |
| 1616 | 1616 | ||
| 1617 | @defspec labels (bindings@dots{}) forms@dots{} | 1617 | @defmac labels (bindings@dots{}) forms@dots{} |
| 1618 | The @code{labels} form is like @code{flet}, except that it | 1618 | The @code{labels} form is like @code{flet}, except that it |
| 1619 | makes lexical bindings of the function names rather than | 1619 | makes lexical bindings of the function names rather than |
| 1620 | dynamic bindings. (In true Common Lisp, both @code{flet} and | 1620 | dynamic bindings. (In true Common Lisp, both @code{flet} and |
| @@ -1635,7 +1635,7 @@ functions. | |||
| 1635 | A ``reference'' to a function name is either a call to that | 1635 | A ``reference'' to a function name is either a call to that |
| 1636 | function, or a use of its name quoted by @code{quote} or | 1636 | function, or a use of its name quoted by @code{quote} or |
| 1637 | @code{function} to be passed on to, say, @code{mapcar}. | 1637 | @code{function} to be passed on to, say, @code{mapcar}. |
| 1638 | @end defspec | 1638 | @end defmac |
| 1639 | 1639 | ||
| 1640 | @node Macro Bindings | 1640 | @node Macro Bindings |
| 1641 | @subsection Macro Bindings | 1641 | @subsection Macro Bindings |
| @@ -1643,7 +1643,7 @@ function, or a use of its name quoted by @code{quote} or | |||
| 1643 | @noindent | 1643 | @noindent |
| 1644 | These forms create local macros and ``symbol macros''. | 1644 | These forms create local macros and ``symbol macros''. |
| 1645 | 1645 | ||
| 1646 | @defspec cl-macrolet (bindings@dots{}) forms@dots{} | 1646 | @defmac cl-macrolet (bindings@dots{}) forms@dots{} |
| 1647 | This form is analogous to @code{flet}, but for macros instead of | 1647 | This form is analogous to @code{flet}, but for macros instead of |
| 1648 | functions. Each @var{binding} is a list of the same form as the | 1648 | functions. Each @var{binding} is a list of the same form as the |
| 1649 | arguments to @code{cl-defmacro} (i.e., a macro name, argument list, | 1649 | arguments to @code{cl-defmacro} (i.e., a macro name, argument list, |
| @@ -1655,9 +1655,9 @@ scoped even in Emacs Lisp: The @code{cl-macrolet} binding will | |||
| 1655 | affect only calls that appear physically within the body | 1655 | affect only calls that appear physically within the body |
| 1656 | @var{forms}, possibly after expansion of other macros in the | 1656 | @var{forms}, possibly after expansion of other macros in the |
| 1657 | body. | 1657 | body. |
| 1658 | @end defspec | 1658 | @end defmac |
| 1659 | 1659 | ||
| 1660 | @defspec cl-symbol-macrolet (bindings@dots{}) forms@dots{} | 1660 | @defmac cl-symbol-macrolet (bindings@dots{}) forms@dots{} |
| 1661 | This form creates @dfn{symbol macros}, which are macros that look | 1661 | This form creates @dfn{symbol macros}, which are macros that look |
| 1662 | like variable references rather than function calls. Each | 1662 | like variable references rather than function calls. Each |
| 1663 | @var{binding} is a list @samp{(@var{var} @var{expansion})}; | 1663 | @var{binding} is a list @samp{(@var{var} @var{expansion})}; |
| @@ -1723,7 +1723,7 @@ which in turn expands to | |||
| 1723 | @xref{Loop Facility}, for a description of the @code{cl-loop} macro. | 1723 | @xref{Loop Facility}, for a description of the @code{cl-loop} macro. |
| 1724 | This package defines a nonstandard @code{in-ref} loop clause that | 1724 | This package defines a nonstandard @code{in-ref} loop clause that |
| 1725 | works much like @code{my-dolist}. | 1725 | works much like @code{my-dolist}. |
| 1726 | @end defspec | 1726 | @end defmac |
| 1727 | 1727 | ||
| 1728 | @node Conditionals | 1728 | @node Conditionals |
| 1729 | @section Conditionals | 1729 | @section Conditionals |
| @@ -1732,7 +1732,7 @@ works much like @code{my-dolist}. | |||
| 1732 | These conditional forms augment Emacs Lisp's simple @code{if}, | 1732 | These conditional forms augment Emacs Lisp's simple @code{if}, |
| 1733 | @code{and}, @code{or}, and @code{cond} forms. | 1733 | @code{and}, @code{or}, and @code{cond} forms. |
| 1734 | 1734 | ||
| 1735 | @defspec cl-case keyform clause@dots{} | 1735 | @defmac cl-case keyform clause@dots{} |
| 1736 | This macro evaluates @var{keyform}, then compares it with the key | 1736 | This macro evaluates @var{keyform}, then compares it with the key |
| 1737 | values listed in the various @var{clause}s. Whichever clause matches | 1737 | values listed in the various @var{clause}s. Whichever clause matches |
| 1738 | the key is executed; comparison is done by @code{eql}. If no clause | 1738 | the key is executed; comparison is done by @code{eql}. If no clause |
| @@ -1766,15 +1766,15 @@ a @key{RET} or @kbd{C-j}, or anything else. | |||
| 1766 | ((?\r ?\n) (do-ret-thing)) | 1766 | ((?\r ?\n) (do-ret-thing)) |
| 1767 | (t (do-other-thing))) | 1767 | (t (do-other-thing))) |
| 1768 | @end example | 1768 | @end example |
| 1769 | @end defspec | 1769 | @end defmac |
| 1770 | 1770 | ||
| 1771 | @defspec cl-ecase keyform clause@dots{} | 1771 | @defmac cl-ecase keyform clause@dots{} |
| 1772 | This macro is just like @code{cl-case}, except that if the key does | 1772 | This macro is just like @code{cl-case}, except that if the key does |
| 1773 | not match any of the clauses, an error is signaled rather than | 1773 | not match any of the clauses, an error is signaled rather than |
| 1774 | simply returning @code{nil}. | 1774 | simply returning @code{nil}. |
| 1775 | @end defspec | 1775 | @end defmac |
| 1776 | 1776 | ||
| 1777 | @defspec cl-typecase keyform clause@dots{} | 1777 | @defmac cl-typecase keyform clause@dots{} |
| 1778 | This macro is a version of @code{cl-case} that checks for types | 1778 | This macro is a version of @code{cl-case} that checks for types |
| 1779 | rather than values. Each @var{clause} is of the form | 1779 | rather than values. Each @var{clause} is of the form |
| 1780 | @samp{(@var{type} @var{body}...)}. @xref{Type Predicates}, | 1780 | @samp{(@var{type} @var{body}...)}. @xref{Type Predicates}, |
| @@ -1791,13 +1791,13 @@ for a description of type specifiers. For example, | |||
| 1791 | The type specifier @code{t} matches any type of object; the word | 1791 | The type specifier @code{t} matches any type of object; the word |
| 1792 | @code{otherwise} is also allowed. To make one clause match any of | 1792 | @code{otherwise} is also allowed. To make one clause match any of |
| 1793 | several types, use an @code{(or ...)} type specifier. | 1793 | several types, use an @code{(or ...)} type specifier. |
| 1794 | @end defspec | 1794 | @end defmac |
| 1795 | 1795 | ||
| 1796 | @defspec cl-etypecase keyform clause@dots{} | 1796 | @defmac cl-etypecase keyform clause@dots{} |
| 1797 | This macro is just like @code{cl-typecase}, except that if the key does | 1797 | This macro is just like @code{cl-typecase}, except that if the key does |
| 1798 | not match any of the clauses, an error is signaled rather than | 1798 | not match any of the clauses, an error is signaled rather than |
| 1799 | simply returning @code{nil}. | 1799 | simply returning @code{nil}. |
| 1800 | @end defspec | 1800 | @end defmac |
| 1801 | 1801 | ||
| 1802 | @node Blocks and Exits | 1802 | @node Blocks and Exits |
| 1803 | @section Blocks and Exits | 1803 | @section Blocks and Exits |
| @@ -1810,7 +1810,7 @@ in terms of @code{catch}; however, the lexical scoping allows the | |||
| 1810 | optimizing byte-compiler to omit the costly @code{catch} step if the | 1810 | optimizing byte-compiler to omit the costly @code{catch} step if the |
| 1811 | body of the block does not actually @code{cl-return-from} the block. | 1811 | body of the block does not actually @code{cl-return-from} the block. |
| 1812 | 1812 | ||
| 1813 | @defspec cl-block name forms@dots{} | 1813 | @defmac cl-block name forms@dots{} |
| 1814 | The @var{forms} are evaluated as if by a @code{progn}. However, | 1814 | The @var{forms} are evaluated as if by a @code{progn}. However, |
| 1815 | if any of the @var{forms} execute @code{(cl-return-from @var{name})}, | 1815 | if any of the @var{forms} execute @code{(cl-return-from @var{name})}, |
| 1816 | they will jump out and return directly from the @code{cl-block} form. | 1816 | they will jump out and return directly from the @code{cl-block} form. |
| @@ -1849,20 +1849,20 @@ not in fact contain any @code{cl-return} or @code{cl-return-from} calls | |||
| 1849 | that jump to it. This means that @code{cl-do} loops and @code{cl-defun} | 1849 | that jump to it. This means that @code{cl-do} loops and @code{cl-defun} |
| 1850 | functions which don't use @code{cl-return} don't pay the overhead to | 1850 | functions which don't use @code{cl-return} don't pay the overhead to |
| 1851 | support it. | 1851 | support it. |
| 1852 | @end defspec | 1852 | @end defmac |
| 1853 | 1853 | ||
| 1854 | @defspec cl-return-from name [result] | 1854 | @defmac cl-return-from name [result] |
| 1855 | This macro returns from the block named @var{name}, which must be | 1855 | This macro returns from the block named @var{name}, which must be |
| 1856 | an (unevaluated) symbol. If a @var{result} form is specified, it | 1856 | an (unevaluated) symbol. If a @var{result} form is specified, it |
| 1857 | is evaluated to produce the result returned from the @code{block}. | 1857 | is evaluated to produce the result returned from the @code{block}. |
| 1858 | Otherwise, @code{nil} is returned. | 1858 | Otherwise, @code{nil} is returned. |
| 1859 | @end defspec | 1859 | @end defmac |
| 1860 | 1860 | ||
| 1861 | @defspec cl-return [result] | 1861 | @defmac cl-return [result] |
| 1862 | This macro is exactly like @code{(cl-return-from nil @var{result})}. | 1862 | This macro is exactly like @code{(cl-return-from nil @var{result})}. |
| 1863 | Common Lisp loops like @code{cl-do} and @code{cl-dolist} implicitly enclose | 1863 | Common Lisp loops like @code{cl-do} and @code{cl-dolist} implicitly enclose |
| 1864 | themselves in @code{nil} blocks. | 1864 | themselves in @code{nil} blocks. |
| 1865 | @end defspec | 1865 | @end defmac |
| 1866 | 1866 | ||
| 1867 | @node Iteration | 1867 | @node Iteration |
| 1868 | @section Iteration | 1868 | @section Iteration |
| @@ -1872,7 +1872,7 @@ The macros described here provide more sophisticated, high-level | |||
| 1872 | looping constructs to complement Emacs Lisp's basic @code{while} | 1872 | looping constructs to complement Emacs Lisp's basic @code{while} |
| 1873 | loop. | 1873 | loop. |
| 1874 | 1874 | ||
| 1875 | @defspec cl-loop forms@dots{} | 1875 | @defmac cl-loop forms@dots{} |
| 1876 | The @code{CL} package supports both the simple, old-style meaning of | 1876 | The @code{CL} package supports both the simple, old-style meaning of |
| 1877 | @code{loop} and the extremely powerful and flexible feature known as | 1877 | @code{loop} and the extremely powerful and flexible feature known as |
| 1878 | the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced | 1878 | the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced |
| @@ -1900,9 +1900,9 @@ interpreted as a Loop Macro specification as described later. | |||
| 1900 | (This is not a restriction in practice, since a plain symbol | 1900 | (This is not a restriction in practice, since a plain symbol |
| 1901 | in the above notation would simply access and throw away the | 1901 | in the above notation would simply access and throw away the |
| 1902 | value of a variable.) | 1902 | value of a variable.) |
| 1903 | @end defspec | 1903 | @end defmac |
| 1904 | 1904 | ||
| 1905 | @defspec cl-do (spec@dots{}) (end-test [result@dots{}]) forms@dots{} | 1905 | @defmac cl-do (spec@dots{}) (end-test [result@dots{}]) forms@dots{} |
| 1906 | This macro creates a general iterative loop. Each @var{spec} is | 1906 | This macro creates a general iterative loop. Each @var{spec} is |
| 1907 | of the form | 1907 | of the form |
| 1908 | 1908 | ||
| @@ -1948,9 +1948,9 @@ the rest of the loop. | |||
| 1948 | ((or (null x) (null y)) | 1948 | ((or (null x) (null y)) |
| 1949 | (nreverse z))) | 1949 | (nreverse z))) |
| 1950 | @end example | 1950 | @end example |
| 1951 | @end defspec | 1951 | @end defmac |
| 1952 | 1952 | ||
| 1953 | @defspec cl-do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{} | 1953 | @defmac cl-do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{} |
| 1954 | This is to @code{cl-do} what @code{let*} is to @code{let}. In | 1954 | This is to @code{cl-do} what @code{let*} is to @code{let}. In |
| 1955 | particular, the initial values are bound as if by @code{let*} | 1955 | particular, the initial values are bound as if by @code{let*} |
| 1956 | rather than @code{let}, and the steps are assigned as if by | 1956 | rather than @code{let}, and the steps are assigned as if by |
| @@ -1968,9 +1968,9 @@ Here is another way to write the above loop: | |||
| 1968 | (nreverse z)) | 1968 | (nreverse z)) |
| 1969 | (push (f x y) z)) | 1969 | (push (f x y) z)) |
| 1970 | @end example | 1970 | @end example |
| 1971 | @end defspec | 1971 | @end defmac |
| 1972 | 1972 | ||
| 1973 | @defspec cl-dolist (var list [result]) forms@dots{} | 1973 | @defmac cl-dolist (var list [result]) forms@dots{} |
| 1974 | This is a more specialized loop which iterates across the elements | 1974 | This is a more specialized loop which iterates across the elements |
| 1975 | of a list. @var{list} should evaluate to a list; the body @var{forms} | 1975 | of a list. @var{list} should evaluate to a list; the body @var{forms} |
| 1976 | are executed with @var{var} bound to each element of the list in | 1976 | are executed with @var{var} bound to each element of the list in |
| @@ -1978,9 +1978,9 @@ turn. Finally, the @var{result} form (or @code{nil}) is evaluated | |||
| 1978 | with @var{var} bound to @code{nil} to produce the result returned by | 1978 | with @var{var} bound to @code{nil} to produce the result returned by |
| 1979 | the loop. Unlike with Emacs's built in @code{dolist}, the loop is | 1979 | the loop. Unlike with Emacs's built in @code{dolist}, the loop is |
| 1980 | surrounded by an implicit @code{nil} block. | 1980 | surrounded by an implicit @code{nil} block. |
| 1981 | @end defspec | 1981 | @end defmac |
| 1982 | 1982 | ||
| 1983 | @defspec cl-dotimes (var count [result]) forms@dots{} | 1983 | @defmac cl-dotimes (var count [result]) forms@dots{} |
| 1984 | This is a more specialized loop which iterates a specified number | 1984 | This is a more specialized loop which iterates a specified number |
| 1985 | of times. The body is executed with @var{var} bound to the integers | 1985 | of times. The body is executed with @var{var} bound to the integers |
| 1986 | from zero (inclusive) to @var{count} (exclusive), in turn. Then | 1986 | from zero (inclusive) to @var{count} (exclusive), in turn. Then |
| @@ -1988,9 +1988,9 @@ the @code{result} form is evaluated with @var{var} bound to the total | |||
| 1988 | number of iterations that were done (i.e., @code{(max 0 @var{count})}) | 1988 | number of iterations that were done (i.e., @code{(max 0 @var{count})}) |
| 1989 | to get the return value for the loop form. Unlike with Emacs's built in | 1989 | to get the return value for the loop form. Unlike with Emacs's built in |
| 1990 | @code{dolist}, the loop is surrounded by an implicit @code{nil} block. | 1990 | @code{dolist}, the loop is surrounded by an implicit @code{nil} block. |
| 1991 | @end defspec | 1991 | @end defmac |
| 1992 | 1992 | ||
| 1993 | @defspec cl-do-symbols (var [obarray [result]]) forms@dots{} | 1993 | @defmac cl-do-symbols (var [obarray [result]]) forms@dots{} |
| 1994 | This loop iterates over all interned symbols. If @var{obarray} | 1994 | This loop iterates over all interned symbols. If @var{obarray} |
| 1995 | is specified and is not @code{nil}, it loops over all symbols in | 1995 | is specified and is not @code{nil}, it loops over all symbols in |
| 1996 | that obarray. For each symbol, the body @var{forms} are evaluated | 1996 | that obarray. For each symbol, the body @var{forms} are evaluated |
| @@ -1998,12 +1998,12 @@ with @var{var} bound to that symbol. The symbols are visited in | |||
| 1998 | an unspecified order. Afterward the @var{result} form, if any, | 1998 | an unspecified order. Afterward the @var{result} form, if any, |
| 1999 | is evaluated (with @var{var} bound to @code{nil}) to get the return | 1999 | is evaluated (with @var{var} bound to @code{nil}) to get the return |
| 2000 | value. The loop is surrounded by an implicit @code{nil} block. | 2000 | value. The loop is surrounded by an implicit @code{nil} block. |
| 2001 | @end defspec | 2001 | @end defmac |
| 2002 | 2002 | ||
| 2003 | @defspec cl-do-all-symbols (var [result]) forms@dots{} | 2003 | @defmac cl-do-all-symbols (var [result]) forms@dots{} |
| 2004 | This is identical to @code{cl-do-symbols} except that the @var{obarray} | 2004 | This is identical to @code{cl-do-symbols} except that the @var{obarray} |
| 2005 | argument is omitted; it always iterates over the default obarray. | 2005 | argument is omitted; it always iterates over the default obarray. |
| 2006 | @end defspec | 2006 | @end defmac |
| 2007 | 2007 | ||
| 2008 | @xref{Mapping over Sequences}, for some more functions for | 2008 | @xref{Mapping over Sequences}, for some more functions for |
| 2009 | iterating over vectors or lists. | 2009 | iterating over vectors or lists. |
| @@ -2043,7 +2043,7 @@ Since @code{cl-loop} is a macro, all parsing of the loop language | |||
| 2043 | takes place at byte-compile time; compiled @code{cl-loop}s are just | 2043 | takes place at byte-compile time; compiled @code{cl-loop}s are just |
| 2044 | as efficient as the equivalent @code{while} loops written longhand. | 2044 | as efficient as the equivalent @code{while} loops written longhand. |
| 2045 | 2045 | ||
| 2046 | @defspec cl-loop clauses@dots{} | 2046 | @defmac cl-loop clauses@dots{} |
| 2047 | A loop construct consists of a series of @var{clause}s, each | 2047 | A loop construct consists of a series of @var{clause}s, each |
| 2048 | introduced by a symbol like @code{for} or @code{do}. Clauses | 2048 | introduced by a symbol like @code{for} or @code{do}. Clauses |
| 2049 | are simply strung together in the argument list of @code{cl-loop}, | 2049 | are simply strung together in the argument list of @code{cl-loop}, |
| @@ -2082,7 +2082,7 @@ explicit @code{return} clause to jump out of the implicit block. | |||
| 2082 | (Because the loop body is enclosed in an implicit block, you can | 2082 | (Because the loop body is enclosed in an implicit block, you can |
| 2083 | also use regular Lisp @code{cl-return} or @code{cl-return-from} to | 2083 | also use regular Lisp @code{cl-return} or @code{cl-return-from} to |
| 2084 | break out of the loop.) | 2084 | break out of the loop.) |
| 2085 | @end defspec | 2085 | @end defmac |
| 2086 | 2086 | ||
| 2087 | The following sections give some examples of the Loop Macro in | 2087 | The following sections give some examples of the Loop Macro in |
| 2088 | action, and describe the particular loop clauses in great detail. | 2088 | action, and describe the particular loop clauses in great detail. |
| @@ -2773,21 +2773,21 @@ in Emacs Lisp these functions simply operate on lists instead. | |||
| 2773 | The @code{values} form, for example, is a synonym for @code{list} | 2773 | The @code{values} form, for example, is a synonym for @code{list} |
| 2774 | in Emacs. | 2774 | in Emacs. |
| 2775 | 2775 | ||
| 2776 | @defspec cl-multiple-value-bind (var@dots{}) values-form forms@dots{} | 2776 | @defmac cl-multiple-value-bind (var@dots{}) values-form forms@dots{} |
| 2777 | This form evaluates @var{values-form}, which must return a list of | 2777 | This form evaluates @var{values-form}, which must return a list of |
| 2778 | values. It then binds the @var{var}s to these respective values, | 2778 | values. It then binds the @var{var}s to these respective values, |
| 2779 | as if by @code{let}, and then executes the body @var{forms}. | 2779 | as if by @code{let}, and then executes the body @var{forms}. |
| 2780 | If there are more @var{var}s than values, the extra @var{var}s | 2780 | If there are more @var{var}s than values, the extra @var{var}s |
| 2781 | are bound to @code{nil}. If there are fewer @var{var}s than | 2781 | are bound to @code{nil}. If there are fewer @var{var}s than |
| 2782 | values, the excess values are ignored. | 2782 | values, the excess values are ignored. |
| 2783 | @end defspec | 2783 | @end defmac |
| 2784 | 2784 | ||
| 2785 | @defspec cl-multiple-value-setq (var@dots{}) form | 2785 | @defmac cl-multiple-value-setq (var@dots{}) form |
| 2786 | This form evaluates @var{form}, which must return a list of values. | 2786 | This form evaluates @var{form}, which must return a list of values. |
| 2787 | It then sets the @var{var}s to these respective values, as if by | 2787 | It then sets the @var{var}s to these respective values, as if by |
| 2788 | @code{setq}. Extra @var{var}s or values are treated the same as | 2788 | @code{setq}. Extra @var{var}s or values are treated the same as |
| 2789 | in @code{cl-multiple-value-bind}. | 2789 | in @code{cl-multiple-value-bind}. |
| 2790 | @end defspec | 2790 | @end defmac |
| 2791 | 2791 | ||
| 2792 | Since a perfect emulation is not feasible in Emacs Lisp, this | 2792 | Since a perfect emulation is not feasible in Emacs Lisp, this |
| 2793 | package opts to keep it as simple and predictable as possible. | 2793 | package opts to keep it as simple and predictable as possible. |
| @@ -2805,7 +2805,7 @@ for @code{defmacro} due to technical difficulties. | |||
| 2805 | Destructuring is made available to the user by way of the | 2805 | Destructuring is made available to the user by way of the |
| 2806 | following macro: | 2806 | following macro: |
| 2807 | 2807 | ||
| 2808 | @defspec cl-destructuring-bind arglist expr forms@dots{} | 2808 | @defmac cl-destructuring-bind arglist expr forms@dots{} |
| 2809 | This macro expands to code which executes @var{forms}, with | 2809 | This macro expands to code which executes @var{forms}, with |
| 2810 | the variables in @var{arglist} bound to the list of values | 2810 | the variables in @var{arglist} bound to the list of values |
| 2811 | returned by @var{expr}. The @var{arglist} can include all | 2811 | returned by @var{expr}. The @var{arglist} can include all |
| @@ -2814,13 +2814,13 @@ including destructuring. (The @code{&environment} keyword | |||
| 2814 | is not allowed.) The macro expansion will signal an error | 2814 | is not allowed.) The macro expansion will signal an error |
| 2815 | if @var{expr} returns a list of the wrong number of arguments | 2815 | if @var{expr} returns a list of the wrong number of arguments |
| 2816 | or with incorrect keyword arguments. | 2816 | or with incorrect keyword arguments. |
| 2817 | @end defspec | 2817 | @end defmac |
| 2818 | 2818 | ||
| 2819 | This package also includes the Common Lisp @code{cl-define-compiler-macro} | 2819 | This package also includes the Common Lisp @code{cl-define-compiler-macro} |
| 2820 | facility, which allows you to define compile-time expansions and | 2820 | facility, which allows you to define compile-time expansions and |
| 2821 | optimizations for your functions. | 2821 | optimizations for your functions. |
| 2822 | 2822 | ||
| 2823 | @defspec cl-define-compiler-macro name arglist forms@dots{} | 2823 | @defmac cl-define-compiler-macro name arglist forms@dots{} |
| 2824 | This form is similar to @code{defmacro}, except that it only expands | 2824 | This form is similar to @code{defmacro}, except that it only expands |
| 2825 | calls to @var{name} at compile-time; calls processed by the Lisp | 2825 | calls to @var{name} at compile-time; calls processed by the Lisp |
| 2826 | interpreter are not expanded, nor are they expanded by the | 2826 | interpreter are not expanded, nor are they expanded by the |
| @@ -2854,7 +2854,7 @@ if there are any keyword arguments in the call, then the original | |||
| 2854 | @code{cl-member} call is left intact. (The actual compiler macro | 2854 | @code{cl-member} call is left intact. (The actual compiler macro |
| 2855 | for @code{cl-member} optimizes a number of other cases, including | 2855 | for @code{cl-member} optimizes a number of other cases, including |
| 2856 | common @code{:test} predicates.) | 2856 | common @code{:test} predicates.) |
| 2857 | @end defspec | 2857 | @end defmac |
| 2858 | 2858 | ||
| 2859 | @defun cl-compiler-macroexpand form | 2859 | @defun cl-compiler-macroexpand form |
| 2860 | This function is analogous to @code{macroexpand}, except that it | 2860 | This function is analogous to @code{macroexpand}, except that it |
| @@ -2896,7 +2896,7 @@ This function records a ``global'' declaration specified by | |||
| 2896 | is evaluated and thus should normally be quoted. | 2896 | is evaluated and thus should normally be quoted. |
| 2897 | @end defun | 2897 | @end defun |
| 2898 | 2898 | ||
| 2899 | @defspec cl-declaim decl-specs@dots{} | 2899 | @defmac cl-declaim decl-specs@dots{} |
| 2900 | This macro is like @code{cl-proclaim}, except that it takes any number | 2900 | This macro is like @code{cl-proclaim}, except that it takes any number |
| 2901 | of @var{decl-spec} arguments, and the arguments are unevaluated and | 2901 | of @var{decl-spec} arguments, and the arguments are unevaluated and |
| 2902 | unquoted. The @code{cl-declaim} macro also puts an @code{(cl-eval-when | 2902 | unquoted. The @code{cl-declaim} macro also puts an @code{(cl-eval-when |
| @@ -2905,22 +2905,22 @@ be registered at compile-time as well as at run-time. (This is vital, | |||
| 2905 | since normally the declarations are meant to influence the way the | 2905 | since normally the declarations are meant to influence the way the |
| 2906 | compiler treats the rest of the file that contains the @code{cl-declaim} | 2906 | compiler treats the rest of the file that contains the @code{cl-declaim} |
| 2907 | form.) | 2907 | form.) |
| 2908 | @end defspec | 2908 | @end defmac |
| 2909 | 2909 | ||
| 2910 | @defspec cl-declare decl-specs@dots{} | 2910 | @defmac cl-declare decl-specs@dots{} |
| 2911 | This macro is used to make declarations within functions and other | 2911 | This macro is used to make declarations within functions and other |
| 2912 | code. Common Lisp allows declarations in various locations, generally | 2912 | code. Common Lisp allows declarations in various locations, generally |
| 2913 | at the beginning of any of the many ``implicit @code{progn}s'' | 2913 | at the beginning of any of the many ``implicit @code{progn}s'' |
| 2914 | throughout Lisp syntax, such as function bodies, @code{let} bodies, | 2914 | throughout Lisp syntax, such as function bodies, @code{let} bodies, |
| 2915 | etc. Currently the only declaration understood by @code{cl-declare} | 2915 | etc. Currently the only declaration understood by @code{cl-declare} |
| 2916 | is @code{special}. | 2916 | is @code{special}. |
| 2917 | @end defspec | 2917 | @end defmac |
| 2918 | 2918 | ||
| 2919 | @defspec cl-locally declarations@dots{} forms@dots{} | 2919 | @defmac cl-locally declarations@dots{} forms@dots{} |
| 2920 | In this package, @code{cl-locally} is no different from @code{progn}. | 2920 | In this package, @code{cl-locally} is no different from @code{progn}. |
| 2921 | @end defspec | 2921 | @end defmac |
| 2922 | 2922 | ||
| 2923 | @defspec cl-the type form | 2923 | @defmac cl-the type form |
| 2924 | Type information provided by @code{cl-the} is ignored in this package; | 2924 | Type information provided by @code{cl-the} is ignored in this package; |
| 2925 | in other words, @code{(cl-the @var{type} @var{form})} is equivalent | 2925 | in other words, @code{(cl-the @var{type} @var{form})} is equivalent |
| 2926 | to @var{form}. Future versions of the optimizing byte-compiler may | 2926 | to @var{form}. Future versions of the optimizing byte-compiler may |
| @@ -2933,7 +2933,7 @@ of time. With @code{(mapcar 'car (cl-the vector foo))}, a future | |||
| 2933 | compiler would have enough information to expand the loop in-line. | 2933 | compiler would have enough information to expand the loop in-line. |
| 2934 | For now, Emacs Lisp will treat the above code as exactly equivalent | 2934 | For now, Emacs Lisp will treat the above code as exactly equivalent |
| 2935 | to @code{(mapcar 'car foo)}. | 2935 | to @code{(mapcar 'car foo)}. |
| 2936 | @end defspec | 2936 | @end defmac |
| 2937 | 2937 | ||
| 2938 | Each @var{decl-spec} in a @code{cl-proclaim}, @code{cl-declaim}, or | 2938 | Each @var{decl-spec} in a @code{cl-proclaim}, @code{cl-declaim}, or |
| 2939 | @code{cl-declare} should be a list beginning with a symbol that says | 2939 | @code{cl-declare} should be a list beginning with a symbol that says |
| @@ -3137,7 +3137,7 @@ function and its @var{place} argument can actually be any Lisp | |||
| 3137 | expression. | 3137 | expression. |
| 3138 | @end defun | 3138 | @end defun |
| 3139 | 3139 | ||
| 3140 | @defspec cl-remf place property | 3140 | @defmac cl-remf place property |
| 3141 | This macro removes the property-value pair for @var{property} from | 3141 | This macro removes the property-value pair for @var{property} from |
| 3142 | the property list stored at @var{place}, which is any @code{setf}-able | 3142 | the property list stored at @var{place}, which is any @code{setf}-able |
| 3143 | place expression. It returns true if the property was found. Note | 3143 | place expression. It returns true if the property was found. Note |
| @@ -3145,7 +3145,7 @@ that if @var{property} happens to be first on the list, this will | |||
| 3145 | effectively do a @code{(setf @var{place} (cddr @var{place}))}, | 3145 | effectively do a @code{(setf @var{place} (cddr @var{place}))}, |
| 3146 | whereas if it occurs later, this simply uses @code{setcdr} to splice | 3146 | whereas if it occurs later, this simply uses @code{setcdr} to splice |
| 3147 | out the property and value cells. | 3147 | out the property and value cells. |
| 3148 | @end defspec | 3148 | @end defmac |
| 3149 | 3149 | ||
| 3150 | @node Creating Symbols | 3150 | @node Creating Symbols |
| 3151 | @section Creating Symbols | 3151 | @section Creating Symbols |
| @@ -4259,7 +4259,7 @@ system provides no way to create new distinct types, this package | |||
| 4259 | implements structures as vectors (or lists upon request) with a | 4259 | implements structures as vectors (or lists upon request) with a |
| 4260 | special ``tag'' symbol to identify them. | 4260 | special ``tag'' symbol to identify them. |
| 4261 | 4261 | ||
| 4262 | @defspec cl-defstruct name slots@dots{} | 4262 | @defmac cl-defstruct name slots@dots{} |
| 4263 | The @code{cl-defstruct} form defines a new structure type called | 4263 | The @code{cl-defstruct} form defines a new structure type called |
| 4264 | @var{name}, with the specified @var{slots}. (The @var{slots} | 4264 | @var{name}, with the specified @var{slots}. (The @var{slots} |
| 4265 | may begin with a string which documents the structure type.) | 4265 | may begin with a string which documents the structure type.) |
| @@ -4563,7 +4563,7 @@ the type @code{:include}s another type, then @code{:initial-offset} | |||
| 4563 | specifies a number of slots to be skipped between the last slot | 4563 | specifies a number of slots to be skipped between the last slot |
| 4564 | of the included type and the first new slot. | 4564 | of the included type and the first new slot. |
| 4565 | @end table | 4565 | @end table |
| 4566 | @end defspec | 4566 | @end defmac |
| 4567 | 4567 | ||
| 4568 | Except as noted, the @code{cl-defstruct} facility of this package is | 4568 | Except as noted, the @code{cl-defstruct} facility of this package is |
| 4569 | entirely compatible with that of Common Lisp. | 4569 | entirely compatible with that of Common Lisp. |
| @@ -4582,7 +4582,7 @@ If the optimization property @code{speed} has been set to 3, and | |||
| 4582 | away the following assertions. Because assertions might be optimized | 4582 | away the following assertions. Because assertions might be optimized |
| 4583 | away, it is a bad idea for them to include side-effects. | 4583 | away, it is a bad idea for them to include side-effects. |
| 4584 | 4584 | ||
| 4585 | @defspec cl-assert test-form [show-args string args@dots{}] | 4585 | @defmac cl-assert test-form [show-args string args@dots{}] |
| 4586 | This form verifies that @var{test-form} is true (i.e., evaluates to | 4586 | This form verifies that @var{test-form} is true (i.e., evaluates to |
| 4587 | a non-@code{nil} value). If so, it returns @code{nil}. If the test | 4587 | a non-@code{nil} value). If so, it returns @code{nil}. If the test |
| 4588 | is not satisfied, @code{cl-assert} signals an error. | 4588 | is not satisfied, @code{cl-assert} signals an error. |
| @@ -4606,9 +4606,9 @@ true Common Lisp, the second argument gives a list of @var{places} | |||
| 4606 | which can be @code{setf}'d by the user before continuing from the | 4606 | which can be @code{setf}'d by the user before continuing from the |
| 4607 | error. Since Emacs Lisp does not support continuable errors, it | 4607 | error. Since Emacs Lisp does not support continuable errors, it |
| 4608 | makes no sense to specify @var{places}. | 4608 | makes no sense to specify @var{places}. |
| 4609 | @end defspec | 4609 | @end defmac |
| 4610 | 4610 | ||
| 4611 | @defspec cl-check-type form type [string] | 4611 | @defmac cl-check-type form type [string] |
| 4612 | This form verifies that @var{form} evaluates to a value of type | 4612 | This form verifies that @var{form} evaluates to a value of type |
| 4613 | @var{type}. If so, it returns @code{nil}. If not, @code{cl-check-type} | 4613 | @var{type}. If so, it returns @code{nil}. If not, @code{cl-check-type} |
| 4614 | signals a @code{wrong-type-argument} error. The default error message | 4614 | signals a @code{wrong-type-argument} error. The default error message |
| @@ -4627,7 +4627,7 @@ Note that in Common Lisp, the first argument to @code{check-type} | |||
| 4627 | must be a @var{place} suitable for use by @code{setf}, because | 4627 | must be a @var{place} suitable for use by @code{setf}, because |
| 4628 | @code{check-type} signals a continuable error that allows the | 4628 | @code{check-type} signals a continuable error that allows the |
| 4629 | user to modify @var{place}. | 4629 | user to modify @var{place}. |
| 4630 | @end defspec | 4630 | @end defmac |
| 4631 | 4631 | ||
| 4632 | @node Efficiency Concerns | 4632 | @node Efficiency Concerns |
| 4633 | @appendix Efficiency Concerns | 4633 | @appendix Efficiency Concerns |
| @@ -4660,12 +4660,10 @@ readable @code{cl-incf} form in your compiled code. | |||
| 4660 | @emph{Interpreted} code, on the other hand, must expand these macros | 4660 | @emph{Interpreted} code, on the other hand, must expand these macros |
| 4661 | every time they are executed. For this reason it is strongly | 4661 | every time they are executed. For this reason it is strongly |
| 4662 | recommended that code making heavy use of macros be compiled. | 4662 | recommended that code making heavy use of macros be compiled. |
| 4663 | @c FIXME why are they not labelled as macros? | 4663 | A loop using @code{cl-incf} a hundred times will execute considerably |
| 4664 | (The features labeled ``Special Form'' instead of ``Function'' in | 4664 | faster if compiled, and will also garbage-collect less because the |
| 4665 | this manual are macros.) A loop using @code{cl-incf} a hundred times | 4665 | macro expansion will not have to be generated, used, and thrown away a |
| 4666 | will execute considerably faster if compiled, and will also | 4666 | hundred times. |
| 4667 | garbage-collect less because the macro expansion will not have | ||
| 4668 | to be generated, used, and thrown away a hundred times. | ||
| 4669 | 4667 | ||
| 4670 | You can find out how a macro expands by using the | 4668 | You can find out how a macro expands by using the |
| 4671 | @code{cl-prettyexpand} function. | 4669 | @code{cl-prettyexpand} function. |