Mercurial > hg > xemacs-beta
comparison man/cl.texi @ 5547:a46c5c8d6564
Avoid calling various macros "special operators" in the manuals.
2011-08-09 Aidan Kehoe <kehoea@parhasard.net>
* cl.texi (Argument Lists):
* cl.texi (Time of Evaluation):
* cl.texi (Type Predicates):
* cl.texi (Assignment):
* cl.texi (Basic Setf):
* cl.texi (Modify Macros):
* cl.texi (Customizing Setf):
* cl.texi (Dynamic Bindings):
* cl.texi (Lexical Bindings):
* cl.texi (Function Bindings):
* cl.texi (Macro Bindings):
* cl.texi (Conditionals):
* cl.texi (Blocks and Exits):
* cl.texi (Iteration):
* cl.texi (Loop Basics):
* cl.texi (Macros):
* cl.texi (Declarations):
* cl.texi (Property Lists):
* cl.texi (Structures):
* cl.texi (Assertions):
* cl.texi (Efficiency Concerns):
* lispref/compile.texi (Eval During Compile):
* lispref/compile.texi (Compiled-Function Objects):
* lispref/eval.texi (Multiple values):
* lispref/frames.texi (Input Focus):
* lispref/internationalization.texi (Level 3 Primitives):
* lispref/positions.texi (Excursions):
* lispref/positions.texi (Narrowing):
* lispref/searching.texi (Saving Match Data):
* lispref/specifiers.texi (Adding Specifications):
* lispref/windows.texi:
Correct the manuals to avoid using the term "special operator" when
#'special-operator-p would give nil.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 09 Aug 2011 17:17:44 +0100 |
parents | 62b9ef1ed4ac |
children | 4654c01af32b |
comparison
equal
deleted
inserted
replaced
5546:d54278e74d71 | 5547:a46c5c8d6564 |
---|---|
379 Since argument parsing is built-in to Emacs, there is no way for | 379 Since argument parsing is built-in to Emacs, there is no way for |
380 this package to implement Common Lisp argument lists seamlessly. | 380 this package to implement Common Lisp argument lists seamlessly. |
381 Instead, this package defines alternates for several Lisp forms | 381 Instead, this package defines alternates for several Lisp forms |
382 which you must use if you need Common Lisp argument lists. | 382 which you must use if you need Common Lisp argument lists. |
383 | 383 |
384 @deffn {Special Operator} defun* name arglist body... | 384 @defmac defun* name arglist body... |
385 This form is identical to the regular @code{defun} form, except | 385 This form is identical to the regular @code{defun} form, except |
386 that @var{arglist} is allowed to be a full Common Lisp argument | 386 that @var{arglist} is allowed to be a full Common Lisp argument |
387 list. Also, the function body is enclosed in an implicit block | 387 list. Also, the function body is enclosed in an implicit block |
388 called @var{name}; @pxref{Blocks and Exits}. | 388 called @var{name}; @pxref{Blocks and Exits}. |
389 @end deffn | 389 @end defmac |
390 | 390 |
391 @deffn {Special Operator} defsubst* name arglist body... | 391 @defmac defsubst* name arglist body... |
392 This is just like @code{defun*}, except that the function that | 392 This is just like @code{defun*}, except that the function that |
393 is defined is automatically proclaimed @code{inline}, i.e., | 393 is defined is automatically proclaimed @code{inline}, i.e., |
394 calls to it may be expanded into in-line code by the byte compiler. | 394 calls to it may be expanded into in-line code by the byte compiler. |
395 This is analogous to the @code{defsubst} form in Emacs 19; | 395 This is analogous to the @code{defsubst} form in Emacs 19; |
396 @code{defsubst*} uses a different method (compiler macros) which | 396 @code{defsubst*} uses a different method (compiler macros) which |
397 works in all version of Emacs, and also generates somewhat more | 397 works in all version of Emacs, and also generates somewhat more |
398 efficient inline expansions. In particular, @code{defsubst*} | 398 efficient inline expansions. In particular, @code{defsubst*} |
399 arranges for the processing of keyword arguments, default values, | 399 arranges for the processing of keyword arguments, default values, |
400 etc., to be done at compile-time whenever possible. | 400 etc., to be done at compile-time whenever possible. |
401 @end deffn | 401 @end defmac |
402 | 402 |
403 @deffn {Special Operator} defmacro* name arglist body... | 403 @defmac defmacro* name arglist body... |
404 This is identical to the regular @code{defmacro} form, | 404 This is identical to the regular @code{defmacro} form, |
405 except that @var{arglist} is allowed to be a full Common Lisp | 405 except that @var{arglist} is allowed to be a full Common Lisp |
406 argument list. The @code{&environment} keyword is supported as | 406 argument list. The @code{&environment} keyword is supported as |
407 described in Steele. The @code{&whole} keyword is supported only | 407 described in Steele. The @code{&whole} keyword is supported only |
408 within destructured lists (see below); top-level @code{&whole} | 408 within destructured lists (see below); top-level @code{&whole} |
409 cannot be implemented with the current Emacs Lisp interpreter. | 409 cannot be implemented with the current Emacs Lisp interpreter. |
410 The macro expander body is enclosed in an implicit block called | 410 The macro expander body is enclosed in an implicit block called |
411 @var{name}. | 411 @var{name}. |
412 @end deffn | 412 @end defmac |
413 | 413 |
414 @deffn {Special Operator} function* symbol-or-lambda | 414 @defmac function* symbol-or-lambda |
415 This is identical to the regular @code{function} form, | 415 This is identical to the regular @code{function} form, |
416 except that if the argument is a @code{lambda} form then that | 416 except that if the argument is a @code{lambda} form then that |
417 form may use a full Common Lisp argument list. | 417 form may use a full Common Lisp argument list. |
418 @end deffn | 418 @end defmac |
419 | 419 |
420 Also, all forms (such as @code{defsetf} and @code{flet}) defined | 420 Also, all forms (such as @code{defsetf} and @code{flet}) defined |
421 in this package that include @var{arglist}s in their syntax allow | 421 in this package that include @var{arglist}s in their syntax allow |
422 full Common Lisp argument lists. | 422 full Common Lisp argument lists. |
423 | 423 |
604 would like to have certain top-level forms evaluated at compile-time. | 604 would like to have certain top-level forms evaluated at compile-time. |
605 For example, the compiler effectively evaluates @code{defmacro} forms | 605 For example, the compiler effectively evaluates @code{defmacro} forms |
606 at compile-time so that later parts of the file can refer to the | 606 at compile-time so that later parts of the file can refer to the |
607 macros that are defined. | 607 macros that are defined. |
608 | 608 |
609 @deffn {Special Operator} eval-when (situations...) forms... | 609 @defmac eval-when (situations...) forms... |
610 This form controls when the body @var{forms} are evaluated. | 610 This form controls when the body @var{forms} are evaluated. |
611 The @var{situations} list may contain any set of the symbols | 611 The @var{situations} list may contain any set of the symbols |
612 @code{compile}, @code{load}, and @code{eval} (or their long-winded | 612 @code{compile}, @code{load}, and @code{eval} (or their long-winded |
613 ANSI equivalents, @code{:compile-toplevel}, @code{:load-toplevel}, | 613 ANSI equivalents, @code{:compile-toplevel}, @code{:load-toplevel}, |
614 and @code{:execute}). | 614 and @code{:execute}). |
676 Note that @code{(eval-when (load eval) @dots{})} is equivalent | 676 Note that @code{(eval-when (load eval) @dots{})} is equivalent |
677 to @code{(progn @dots{})} in all contexts. The compiler treats | 677 to @code{(progn @dots{})} in all contexts. The compiler treats |
678 certain top-level forms, like @code{defmacro} (sort-of) and | 678 certain top-level forms, like @code{defmacro} (sort-of) and |
679 @code{require}, as if they were wrapped in @code{(eval-when | 679 @code{require}, as if they were wrapped in @code{(eval-when |
680 (compile load eval) @dots{})}. | 680 (compile load eval) @dots{})}. |
681 @end deffn | 681 @end defmac |
682 | 682 |
683 Emacs 19 includes two special operators related to @code{eval-when}. | 683 Emacs 19 includes two special operators related to @code{eval-when}. |
684 One of these, @code{eval-when-compile}, is not quite equivalent to | 684 One of these, @code{eval-when-compile}, is not quite equivalent to |
685 any @code{eval-when} construct and is described below. This package | 685 any @code{eval-when} construct and is described below. This package |
686 defines a version of @code{eval-when-compile} for the benefit of | 686 defines a version of @code{eval-when-compile} for the benefit of |
688 | 688 |
689 The other form, @code{(eval-and-compile @dots{})}, is exactly | 689 The other form, @code{(eval-and-compile @dots{})}, is exactly |
690 equivalent to @samp{(eval-when (compile load eval) @dots{})} and | 690 equivalent to @samp{(eval-when (compile load eval) @dots{})} and |
691 so is not itself defined by this package. | 691 so is not itself defined by this package. |
692 | 692 |
693 @deffn {Special Operator} eval-when-compile forms... | 693 @defmac eval-when-compile forms... |
694 The @var{forms} are evaluated at compile-time; at execution time, | 694 The @var{forms} are evaluated at compile-time; at execution time, |
695 this form acts like a quoted constant of the resulting value. Used | 695 this form acts like a quoted constant of the resulting value. Used |
696 at top-level, @code{eval-when-compile} is just like @samp{eval-when | 696 at top-level, @code{eval-when-compile} is just like @samp{eval-when |
697 (compile eval)}. In other contexts, @code{eval-when-compile} | 697 (compile eval)}. In other contexts, @code{eval-when-compile} |
698 allows code to be evaluated once at compile-time for efficiency | 698 allows code to be evaluated once at compile-time for efficiency |
699 or other reasons. | 699 or other reasons. |
700 | 700 |
701 This form is similar to the @samp{#.} syntax of true Common Lisp. | 701 This form is similar to the @samp{#.} syntax of true Common Lisp. |
702 @end deffn | 702 @end defmac |
703 | 703 |
704 @deffn {Special Operator} load-time-value form | 704 @defmac load-time-value form |
705 The @var{form} is evaluated at load-time; at execution time, | 705 The @var{form} is evaluated at load-time; at execution time, |
706 this form acts like a quoted constant of the resulting value. | 706 this form acts like a quoted constant of the resulting value. |
707 | 707 |
708 Early Common Lisp had a @samp{#,} syntax that was similar to | 708 Early Common Lisp had a @samp{#,} syntax that was similar to |
709 this, but ANSI Common Lisp replaced it with @code{load-time-value} | 709 this, but ANSI Common Lisp replaced it with @code{load-time-value} |
740 ", compiled on: " | 740 ", compiled on: " |
741 '"Wed Jun 23 18:33:43 1993" | 741 '"Wed Jun 23 18:33:43 1993" |
742 ", and loaded on: " | 742 ", and loaded on: " |
743 --temp--)) | 743 --temp--)) |
744 @end example | 744 @end example |
745 @end deffn | 745 @end defmac |
746 | 746 |
747 @node Function Aliases, , Time of Evaluation, Program Structure | 747 @node Function Aliases, , Time of Evaluation, Program Structure |
748 @section Function Aliases | 748 @section Function Aliases |
749 | 749 |
750 @noindent | 750 @noindent |
867 then integers can be coerced in versions of Emacs that support | 867 then integers can be coerced in versions of Emacs that support |
868 floats. In all other circumstances, @code{coerce} signals an | 868 floats. In all other circumstances, @code{coerce} signals an |
869 error. | 869 error. |
870 @end defun | 870 @end defun |
871 | 871 |
872 @deffn {Special Operator} deftype name arglist forms... | 872 @defmac deftype name arglist forms... |
873 This macro defines a new type called @var{name}. It is similar | 873 This macro defines a new type called @var{name}. It is similar |
874 to @code{defmacro} in many ways; when @var{name} is encountered | 874 to @code{defmacro} in many ways; when @var{name} is encountered |
875 as a type name, the body @var{forms} are evaluated and should | 875 as a type name, the body @var{forms} are evaluated and should |
876 return a type specifier that is equivalent to the type. The | 876 return a type specifier that is equivalent to the type. The |
877 @var{arglist} is a Common Lisp argument list of the sort accepted | 877 @var{arglist} is a Common Lisp argument list of the sort accepted |
895 | 895 |
896 @noindent | 896 @noindent |
897 The last example shows how the Common Lisp @code{unsigned-byte} | 897 The last example shows how the Common Lisp @code{unsigned-byte} |
898 type specifier could be implemented if desired; this package does | 898 type specifier could be implemented if desired; this package does |
899 not implement @code{unsigned-byte} by default. | 899 not implement @code{unsigned-byte} by default. |
900 @end deffn | 900 @end defmac |
901 | 901 |
902 The @code{typecase} and @code{check-type} macros also use type | 902 The @code{typecase} and @code{check-type} macros also use type |
903 names. @xref{Conditionals}. @xref{Assertions}. The @code{map}, | 903 names. @xref{Conditionals}. @xref{Assertions}. The @code{map}, |
904 @code{concatenate}, and @code{merge} functions take type-name | 904 @code{concatenate}, and @code{merge} functions take type-name |
905 arguments to specify the type of sequence to return. @xref{Sequences}. | 905 arguments to specify the type of sequence to return. @xref{Sequences}. |
987 | 987 |
988 @noindent | 988 @noindent |
989 The @code{psetq} form is just like @code{setq}, except that multiple | 989 The @code{psetq} form is just like @code{setq}, except that multiple |
990 assignments are done in parallel rather than sequentially. | 990 assignments are done in parallel rather than sequentially. |
991 | 991 |
992 @deffn {Special Operator} psetq [symbol form]@dots{} | 992 @defmac psetq [symbol form]@dots{} |
993 This macro is used to assign to several | 993 This macro is used to assign to several |
994 variables simultaneously. Given only one @var{symbol} and @var{form}, | 994 variables simultaneously. Given only one @var{symbol} and @var{form}, |
995 it has the same effect as @code{setq}. Given several @var{symbol} | 995 it has the same effect as @code{setq}. Given several @var{symbol} |
996 and @var{form} pairs, it evaluates all the @var{form}s in advance | 996 and @var{form} pairs, it evaluates all the @var{form}s in advance |
997 and then stores the corresponding variables afterwards. | 997 and then stores the corresponding variables afterwards. |
1015 exchanges the values of two variables. (The @code{rotatef} form | 1015 exchanges the values of two variables. (The @code{rotatef} form |
1016 provides an even more convenient way to swap two variables; | 1016 provides an even more convenient way to swap two variables; |
1017 @pxref{Modify Macros}.) | 1017 @pxref{Modify Macros}.) |
1018 | 1018 |
1019 @code{psetq} always returns @code{nil}. | 1019 @code{psetq} always returns @code{nil}. |
1020 @end deffn | 1020 @end defmac |
1021 | 1021 |
1022 @node Generalized Variables, Variable Bindings, Assignment, Control Structure | 1022 @node Generalized Variables, Variable Bindings, Assignment, Control Structure |
1023 @section Generalized Variables | 1023 @section Generalized Variables |
1024 | 1024 |
1025 @noindent | 1025 @noindent |
1053 | 1053 |
1054 @noindent | 1054 @noindent |
1055 The @code{setf} macro is the most basic way to operate on generalized | 1055 The @code{setf} macro is the most basic way to operate on generalized |
1056 variables. | 1056 variables. |
1057 | 1057 |
1058 @deffn {Special Operator} setf [place form]@dots{} | 1058 @defmac setf [place form]@dots{} |
1059 This macro evaluates @var{form} and stores it in @var{place}, which | 1059 This macro evaluates @var{form} and stores it in @var{place}, which |
1060 must be a valid generalized variable form. If there are several | 1060 must be a valid generalized variable form. If there are several |
1061 @var{place} and @var{form} pairs, the assignments are done sequentially | 1061 @var{place} and @var{form} pairs, the assignments are done sequentially |
1062 just as with @code{setq}. @code{setf} returns the value of the last | 1062 just as with @code{setq}. @code{setf} returns the value of the last |
1063 @var{form}. | 1063 @var{form}. |
1216 | 1216 |
1217 @noindent | 1217 @noindent |
1218 the form @code{(setf (wrong-order @var{a} @var{b}) 17)} will | 1218 the form @code{(setf (wrong-order @var{a} @var{b}) 17)} will |
1219 evaluate @var{b} first, then @var{a}, just as in an actual call | 1219 evaluate @var{b} first, then @var{a}, just as in an actual call |
1220 to @code{wrong-order}. | 1220 to @code{wrong-order}. |
1221 @end deffn | 1221 @end defmac |
1222 | 1222 |
1223 @node Modify Macros, Customizing Setf, Basic Setf, Generalized Variables | 1223 @node Modify Macros, Customizing Setf, Basic Setf, Generalized Variables |
1224 @subsection Modify Macros | 1224 @subsection Modify Macros |
1225 | 1225 |
1226 @noindent | 1226 @noindent |
1227 This package defines a number of other macros besides @code{setf} | 1227 This package defines a number of other macros besides @code{setf} |
1228 that operate on generalized variables. Many are interesting and | 1228 that operate on generalized variables. Many are interesting and |
1229 useful even when the @var{place} is just a variable name. | 1229 useful even when the @var{place} is just a variable name. |
1230 | 1230 |
1231 @deffn {Special Operator} psetf [place form]@dots{} | 1231 @defmac psetf [place form]@dots{} |
1232 This macro is to @code{setf} what @code{psetq} is to @code{setq}: | 1232 This macro is to @code{setf} what @code{psetq} is to @code{setq}: |
1233 When several @var{place}s and @var{form}s are involved, the | 1233 When several @var{place}s and @var{form}s are involved, the |
1234 assignments take place in parallel rather than sequentially. | 1234 assignments take place in parallel rather than sequentially. |
1235 Specifically, all subforms are evaluated from left to right, then | 1235 Specifically, all subforms are evaluated from left to right, then |
1236 all the assignments are done (in an undefined order). | 1236 all the assignments are done (in an undefined order). |
1237 @end deffn | 1237 @end defmac |
1238 | 1238 |
1239 @deffn {Special Operator} incf place &optional x | 1239 @defmac incf place &optional x |
1240 This macro increments the number stored in @var{place} by one, or | 1240 This macro increments the number stored in @var{place} by one, or |
1241 by @var{x} if specified. The incremented value is returned. For | 1241 by @var{x} if specified. The incremented value is returned. For |
1242 example, @code{(incf i)} is equivalent to @code{(setq i (1+ i))}, and | 1242 example, @code{(incf i)} is equivalent to @code{(setq i (1+ i))}, and |
1243 @code{(incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}. | 1243 @code{(incf (car x) 2)} is equivalent to @code{(setcar x (+ (car x) 2))}. |
1244 | 1244 |
1272 the other generalized-variable macros. | 1272 the other generalized-variable macros. |
1273 | 1273 |
1274 As a more Emacs-specific example of @code{incf}, the expression | 1274 As a more Emacs-specific example of @code{incf}, the expression |
1275 @code{(incf (point) @var{n})} is essentially equivalent to | 1275 @code{(incf (point) @var{n})} is essentially equivalent to |
1276 @code{(forward-char @var{n})}. | 1276 @code{(forward-char @var{n})}. |
1277 @end deffn | 1277 @end defmac |
1278 | 1278 |
1279 @deffn {Special Operator} decf place &optional x | 1279 @defmac decf place &optional x |
1280 This macro decrements the number stored in @var{place} by one, or | 1280 This macro decrements the number stored in @var{place} by one, or |
1281 by @var{x} if specified. | 1281 by @var{x} if specified. |
1282 @end deffn | 1282 @end defmac |
1283 | 1283 |
1284 @deffn {Special Operator} pop place | 1284 @defmac pop place |
1285 This macro removes and returns the first element of the list stored | 1285 This macro removes and returns the first element of the list stored |
1286 in @var{place}. It is analogous to @code{(prog1 (car @var{place}) | 1286 in @var{place}. It is analogous to @code{(prog1 (car @var{place}) |
1287 (setf @var{place} (cdr @var{place})))}, except that it takes care | 1287 (setf @var{place} (cdr @var{place})))}, except that it takes care |
1288 to evaluate all subforms only once. | 1288 to evaluate all subforms only once. |
1289 @end deffn | 1289 @end defmac |
1290 | 1290 |
1291 @deffn {Special Operator} push x place | 1291 @defmac push x place |
1292 This macro inserts @var{x} at the front of the list stored in | 1292 This macro inserts @var{x} at the front of the list stored in |
1293 @var{place}. It is analogous to @code{(setf @var{place} (cons | 1293 @var{place}. It is analogous to @code{(setf @var{place} (cons |
1294 @var{x} @var{place}))}, except for evaluation of the subforms. | 1294 @var{x} @var{place}))}, except for evaluation of the subforms. |
1295 @end deffn | 1295 @end defmac |
1296 | 1296 |
1297 @deffn {Special Operator} pushnew x place @t{&key :test :test-not :key} | 1297 @defmac pushnew x place @t{&key :test :test-not :key} |
1298 This macro inserts @var{x} at the front of the list stored in | 1298 This macro inserts @var{x} at the front of the list stored in |
1299 @var{place}, but only if @var{x} was not @code{eql} to any | 1299 @var{place}, but only if @var{x} was not @code{eql} to any |
1300 existing element of the list. The optional keyword arguments | 1300 existing element of the list. The optional keyword arguments |
1301 are interpreted in the same way as for @code{adjoin}. | 1301 are interpreted in the same way as for @code{adjoin}. |
1302 @xref{Lists as Sets}. | 1302 @xref{Lists as Sets}. |
1303 @end deffn | 1303 @end defmac |
1304 | 1304 |
1305 @deffn {Special Operator} shiftf place@dots{} newvalue | 1305 @defmac shiftf place@dots{} newvalue |
1306 This macro shifts the @var{place}s left by one, shifting in the | 1306 This macro shifts the @var{place}s left by one, shifting in the |
1307 value of @var{newvalue} (which may be any Lisp expression, not just | 1307 value of @var{newvalue} (which may be any Lisp expression, not just |
1308 a generalized variable), and returning the value shifted out of | 1308 a generalized variable), and returning the value shifted out of |
1309 the first @var{place}. Thus, @code{(shiftf @var{a} @var{b} @var{c} | 1309 the first @var{place}. Thus, @code{(shiftf @var{a} @var{b} @var{c} |
1310 @var{d})} is equivalent to | 1310 @var{d})} is equivalent to |
1318 @end example | 1318 @end example |
1319 | 1319 |
1320 @noindent | 1320 @noindent |
1321 except that the subforms of @var{a}, @var{b}, and @var{c} are actually | 1321 except that the subforms of @var{a}, @var{b}, and @var{c} are actually |
1322 evaluated only once each and in the apparent order. | 1322 evaluated only once each and in the apparent order. |
1323 @end deffn | 1323 @end defmac |
1324 | 1324 |
1325 @deffn {Special Operator} rotatef place@dots{} | 1325 @defmac rotatef place@dots{} |
1326 This macro rotates the @var{place}s left by one in circular fashion. | 1326 This macro rotates the @var{place}s left by one in circular fashion. |
1327 Thus, @code{(rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to | 1327 Thus, @code{(rotatef @var{a} @var{b} @var{c} @var{d})} is equivalent to |
1328 | 1328 |
1329 @example | 1329 @example |
1330 (psetf @var{a} @var{b} | 1330 (psetf @var{a} @var{b} |
1335 | 1335 |
1336 @noindent | 1336 @noindent |
1337 except for the evaluation of subforms. @code{rotatef} always | 1337 except for the evaluation of subforms. @code{rotatef} always |
1338 returns @code{nil}. Note that @code{(rotatef @var{a} @var{b})} | 1338 returns @code{nil}. Note that @code{(rotatef @var{a} @var{b})} |
1339 conveniently exchanges @var{a} and @var{b}. | 1339 conveniently exchanges @var{a} and @var{b}. |
1340 @end deffn | 1340 @end defmac |
1341 | 1341 |
1342 The following macros were invented for this package; they have no | 1342 The following macros were invented for this package; they have no |
1343 analogues in Common Lisp. | 1343 analogues in Common Lisp. |
1344 | 1344 |
1345 @deffn {Special Operator} letf (bindings@dots{}) forms@dots{} | 1345 @defmac letf (bindings@dots{}) forms@dots{} |
1346 This macro is analogous to @code{let}, but for generalized variables | 1346 This macro is analogous to @code{let}, but for generalized variables |
1347 rather than just symbols. Each @var{binding} should be of the form | 1347 rather than just symbols. Each @var{binding} should be of the form |
1348 @code{(@var{place} @var{value})}; the original contents of the | 1348 @code{(@var{place} @var{value})}; the original contents of the |
1349 @var{place}s are saved, the @var{value}s are stored in them, and | 1349 @var{place}s are saved, the @var{value}s are stored in them, and |
1350 then the body @var{form}s are executed. Afterwards, the @var{places} | 1350 then the body @var{form}s are executed. Afterwards, the @var{places} |
1390 In most cases, the @var{place} must have a well-defined value on | 1390 In most cases, the @var{place} must have a well-defined value on |
1391 entry to the @code{letf} form. The only exceptions are plain | 1391 entry to the @code{letf} form. The only exceptions are plain |
1392 variables and calls to @code{symbol-value} and @code{symbol-function}. | 1392 variables and calls to @code{symbol-value} and @code{symbol-function}. |
1393 If the symbol is not bound on entry, it is simply made unbound by | 1393 If the symbol is not bound on entry, it is simply made unbound by |
1394 @code{makunbound} or @code{fmakunbound} on exit. | 1394 @code{makunbound} or @code{fmakunbound} on exit. |
1395 @end deffn | 1395 @end defmac |
1396 | 1396 |
1397 @deffn {Special Operator} letf* (bindings@dots{}) forms@dots{} | 1397 @defmac letf* (bindings@dots{}) forms@dots{} |
1398 This macro is to @code{letf} what @code{let*} is to @code{let}: | 1398 This macro is to @code{letf} what @code{let*} is to @code{let}: |
1399 It does the bindings in sequential rather than parallel order. | 1399 It does the bindings in sequential rather than parallel order. |
1400 @end deffn | 1400 @end defmac |
1401 | 1401 |
1402 @deffn {Special Operator} callf @var{function} @var{place} @var{args}@dots{} | 1402 @defmac callf @var{function} @var{place} @var{args}@dots{} |
1403 This is the ``generic'' modify macro. It calls @var{function}, | 1403 This is the ``generic'' modify macro. It calls @var{function}, |
1404 which should be an unquoted function name, macro name, or lambda. | 1404 which should be an unquoted function name, macro name, or lambda. |
1405 It passes @var{place} and @var{args} as arguments, and assigns the | 1405 It passes @var{place} and @var{args} as arguments, and assigns the |
1406 result back to @var{place}. For example, @code{(incf @var{place} | 1406 result back to @var{place}. For example, @code{(incf @var{place} |
1407 @var{n})} is the same as @code{(callf + @var{place} @var{n})}. | 1407 @var{n})} is the same as @code{(callf + @var{place} @var{n})}. |
1414 @end example | 1414 @end example |
1415 | 1415 |
1416 @xref{Customizing Setf}, for @code{define-modify-macro}, a way | 1416 @xref{Customizing Setf}, for @code{define-modify-macro}, a way |
1417 to create even more concise notations for modify macros. Note | 1417 to create even more concise notations for modify macros. Note |
1418 again that @code{callf} is an extension to standard Common Lisp. | 1418 again that @code{callf} is an extension to standard Common Lisp. |
1419 @end deffn | 1419 @end defmac |
1420 | 1420 |
1421 @deffn {Special Operator} callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{} | 1421 @defmac callf2 @var{function} @var{arg1} @var{place} @var{args}@dots{} |
1422 This macro is like @code{callf}, except that @var{place} is | 1422 This macro is like @code{callf}, except that @var{place} is |
1423 the @emph{second} argument of @var{function} rather than the | 1423 the @emph{second} argument of @var{function} rather than the |
1424 first. For example, @code{(push @var{x} @var{place})} is | 1424 first. For example, @code{(push @var{x} @var{place})} is |
1425 equivalent to @code{(callf2 cons @var{x} @var{place})}. | 1425 equivalent to @code{(callf2 cons @var{x} @var{place})}. |
1426 @end deffn | 1426 @end defmac |
1427 | 1427 |
1428 The @code{callf} and @code{callf2} macros serve as building | 1428 The @code{callf} and @code{callf2} macros serve as building |
1429 blocks for other macros like @code{incf}, @code{pushnew}, and | 1429 blocks for other macros like @code{incf}, @code{pushnew}, and |
1430 @code{define-modify-macro}. The @code{letf} and @code{letf*} | 1430 @code{define-modify-macro}. The @code{letf} and @code{letf*} |
1431 macros are used in the processing of symbol macros; | 1431 macros are used in the processing of symbol macros; |
1437 @noindent | 1437 @noindent |
1438 Common Lisp defines three macros, @code{define-modify-macro}, | 1438 Common Lisp defines three macros, @code{define-modify-macro}, |
1439 @code{defsetf}, and @code{define-setf-method}, that allow the | 1439 @code{defsetf}, and @code{define-setf-method}, that allow the |
1440 user to extend generalized variables in various ways. | 1440 user to extend generalized variables in various ways. |
1441 | 1441 |
1442 @deffn {Special Operator} define-modify-macro name arglist function [doc-string] | 1442 @defmac define-modify-macro name arglist function [doc-string] |
1443 This macro defines a ``read-modify-write'' macro similar to | 1443 This macro defines a ``read-modify-write'' macro similar to |
1444 @code{incf} and @code{decf}. The macro @var{name} is defined | 1444 @code{incf} and @code{decf}. The macro @var{name} is defined |
1445 to take a @var{place} argument followed by additional arguments | 1445 to take a @var{place} argument followed by additional arguments |
1446 described by @var{arglist}. The call | 1446 described by @var{arglist}. The call |
1447 | 1447 |
1478 @code{push} takes its arguments in the wrong order, and @code{pop} | 1478 @code{push} takes its arguments in the wrong order, and @code{pop} |
1479 is completely irregular. You can define these macros ``by hand'' | 1479 is completely irregular. You can define these macros ``by hand'' |
1480 using @code{get-setf-method}, or consult the source file | 1480 using @code{get-setf-method}, or consult the source file |
1481 @file{cl-macs.el} to see how to use the internal @code{setf} | 1481 @file{cl-macs.el} to see how to use the internal @code{setf} |
1482 building blocks. | 1482 building blocks. |
1483 @end deffn | 1483 @end defmac |
1484 | 1484 |
1485 @deffn {Special Operator} defsetf access-fn update-fn | 1485 @defmac defsetf access-fn update-fn |
1486 This is the simpler of two @code{defsetf} forms. Where | 1486 This is the simpler of two @code{defsetf} forms. Where |
1487 @var{access-fn} is the name of a function which accesses a place, | 1487 @var{access-fn} is the name of a function which accesses a place, |
1488 this declares @var{update-fn} to be the corresponding store | 1488 this declares @var{update-fn} to be the corresponding store |
1489 function. From now on, | 1489 function. From now on, |
1490 | 1490 |
1523 @example | 1523 @example |
1524 (defsetf car setcar) | 1524 (defsetf car setcar) |
1525 (defsetf symbol-value set) | 1525 (defsetf symbol-value set) |
1526 (defsetf buffer-name rename-buffer t) | 1526 (defsetf buffer-name rename-buffer t) |
1527 @end example | 1527 @end example |
1528 @end deffn | 1528 @end defmac |
1529 | 1529 |
1530 @deffn {Special Operator} defsetf access-fn arglist (store-var) forms@dots{} | 1530 @defmac defsetf access-fn arglist (store-var) forms@dots{} |
1531 This is the second, more complex, form of @code{defsetf}. It is | 1531 This is the second, more complex, form of @code{defsetf}. It is |
1532 rather like @code{defmacro} except for the additional @var{store-var} | 1532 rather like @code{defmacro} except for the additional @var{store-var} |
1533 argument. The @var{forms} should return a Lisp form which stores | 1533 argument. The @var{forms} should return a Lisp form which stores |
1534 the value of @var{store-var} into the generalized variable formed | 1534 the value of @var{store-var} into the generalized variable formed |
1535 by a call to @var{access-fn} with arguments described by @var{arglist}. | 1535 by a call to @var{access-fn} with arguments described by @var{arglist}. |
1554 | 1554 |
1555 @example | 1555 @example |
1556 (defsetf nth (n x) (store) | 1556 (defsetf nth (n x) (store) |
1557 (list 'setcar (list 'nthcdr n x) store)) | 1557 (list 'setcar (list 'nthcdr n x) store)) |
1558 @end example | 1558 @end example |
1559 @end deffn | 1559 @end defmac |
1560 | 1560 |
1561 @deffn {Special Operator} define-setf-method access-fn arglist forms@dots{} | 1561 @defmac define-setf-method access-fn arglist forms@dots{} |
1562 This is the most general way to create new place forms. When | 1562 This is the most general way to create new place forms. When |
1563 a @code{setf} to @var{access-fn} with arguments described by | 1563 a @code{setf} to @var{access-fn} with arguments described by |
1564 @var{arglist} is expanded, the @var{forms} are evaluated and | 1564 @var{arglist} is expanded, the @var{forms} are evaluated and |
1565 must return a list of five items: | 1565 must return a list of five items: |
1566 | 1566 |
1601 list of a corresponding number of temporary variables generated | 1601 list of a corresponding number of temporary variables generated |
1602 by @code{gensym}. Macros like @code{setf} and @code{incf} which | 1602 by @code{gensym}. Macros like @code{setf} and @code{incf} which |
1603 use this setf-method will optimize away most temporaries that | 1603 use this setf-method will optimize away most temporaries that |
1604 turn out to be unnecessary, so there is little reason for the | 1604 turn out to be unnecessary, so there is little reason for the |
1605 setf-method itself to optimize. | 1605 setf-method itself to optimize. |
1606 @end deffn | 1606 @end defmac |
1607 | 1607 |
1608 @defun get-setf-method place &optional env | 1608 @defun get-setf-method place &optional env |
1609 This function returns the setf-method for @var{place}, by | 1609 This function returns the setf-method for @var{place}, by |
1610 invoking the definition previously recorded by @code{defsetf} | 1610 invoking the definition previously recorded by @code{defsetf} |
1611 or @code{define-setf-method}. The result is a list of five | 1611 or @code{define-setf-method}. The result is a list of five |
1667 @noindent | 1667 @noindent |
1668 The standard @code{let} form binds variables whose names are known | 1668 The standard @code{let} form binds variables whose names are known |
1669 at compile-time. The @code{progv} form provides an easy way to | 1669 at compile-time. The @code{progv} form provides an easy way to |
1670 bind variables whose names are computed at run-time. | 1670 bind variables whose names are computed at run-time. |
1671 | 1671 |
1672 @deffn {Special Operator} progv symbols values forms@dots{} | 1672 @defmac progv symbols values forms@dots{} |
1673 This form establishes @code{let}-style variable bindings on a | 1673 This form establishes @code{let}-style variable bindings on a |
1674 set of variables computed at run-time. The expressions | 1674 set of variables computed at run-time. The expressions |
1675 @var{symbols} and @var{values} are evaluated, and must return lists | 1675 @var{symbols} and @var{values} are evaluated, and must return lists |
1676 of symbols and values, respectively. The symbols are bound to the | 1676 of symbols and values, respectively. The symbols are bound to the |
1677 corresponding values for the duration of the body @var{form}s. | 1677 corresponding values for the duration of the body @var{form}s. |
1678 If @var{values} is shorter than @var{symbols}, the last few symbols | 1678 If @var{values} is shorter than @var{symbols}, the last few symbols |
1679 are made unbound (as if by @code{makunbound}) inside the body. | 1679 are made unbound (as if by @code{makunbound}) inside the body. |
1680 If @var{symbols} is shorter than @var{values}, the excess values | 1680 If @var{symbols} is shorter than @var{values}, the excess values |
1681 are ignored. | 1681 are ignored. |
1682 @end deffn | 1682 @end defmac |
1683 | 1683 |
1684 @node Lexical Bindings, Function Bindings, Dynamic Bindings, Variable Bindings | 1684 @node Lexical Bindings, Function Bindings, Dynamic Bindings, Variable Bindings |
1685 @subsection Lexical Bindings | 1685 @subsection Lexical Bindings |
1686 | 1686 |
1687 @noindent | 1687 @noindent |
1688 The @dfn{CL} package defines the following macro which | 1688 The @dfn{CL} package defines the following macro which |
1689 more closely follows the Common Lisp @code{let} form: | 1689 more closely follows the Common Lisp @code{let} form: |
1690 | 1690 |
1691 @deffn {Special Operator} lexical-let (bindings@dots{}) forms@dots{} | 1691 @defmac lexical-let (bindings@dots{}) forms@dots{} |
1692 This form is exactly like @code{let} except that the bindings it | 1692 This form is exactly like @code{let} except that the bindings it |
1693 establishes are purely lexical. Lexical bindings are similar to | 1693 establishes are purely lexical. Lexical bindings are similar to |
1694 local variables in a language like C: Only the code physically | 1694 local variables in a language like C: Only the code physically |
1695 within the body of the @code{lexical-let} (after macro expansion) | 1695 within the body of the @code{lexical-let} (after macro expansion) |
1696 may refer to the bound variables. | 1696 may refer to the bound variables. |
1786 body of a single @code{lexical-let}, they all close over the same | 1786 body of a single @code{lexical-let}, they all close over the same |
1787 instance of the lexical variable. | 1787 instance of the lexical variable. |
1788 | 1788 |
1789 The @code{lexical-let} form is an extension to Common Lisp. In | 1789 The @code{lexical-let} form is an extension to Common Lisp. In |
1790 true Common Lisp, all bindings are lexical unless declared otherwise. | 1790 true Common Lisp, all bindings are lexical unless declared otherwise. |
1791 @end deffn | 1791 @end defmac |
1792 | 1792 |
1793 @deffn {Special Operator} lexical-let* (bindings@dots{}) forms@dots{} | 1793 @defmac lexical-let* (bindings@dots{}) forms@dots{} |
1794 This form is just like @code{lexical-let}, except that the bindings | 1794 This form is just like @code{lexical-let}, except that the bindings |
1795 are made sequentially in the manner of @code{let*}. | 1795 are made sequentially in the manner of @code{let*}. |
1796 @end deffn | 1796 @end defmac |
1797 | 1797 |
1798 @node Function Bindings, Macro Bindings, Lexical Bindings, Variable Bindings | 1798 @node Function Bindings, Macro Bindings, Lexical Bindings, Variable Bindings |
1799 @subsection Function Bindings | 1799 @subsection Function Bindings |
1800 | 1800 |
1801 @noindent | 1801 @noindent |
1802 These forms make @code{let}-like bindings to functions instead | 1802 These forms make @code{let}-like bindings to functions instead |
1803 of variables. | 1803 of variables. |
1804 | 1804 |
1805 @deffn {Special Operator} flet (bindings@dots{}) forms@dots{} | 1805 @defmac flet (bindings@dots{}) forms@dots{} |
1806 This form establishes @code{let}-style bindings on the function | 1806 This form establishes @code{let}-style bindings on the function |
1807 cells of symbols rather than on the value cells. Each @var{binding} | 1807 cells of symbols rather than on the value cells. Each @var{binding} |
1808 must be a list of the form @samp{(@var{name} @var{arglist} | 1808 must be a list of the form @samp{(@var{name} @var{arglist} |
1809 @var{forms}@dots{})}, which defines a function exactly as if | 1809 @var{forms}@dots{})}, which defines a function exactly as if |
1810 it were a @code{defun*} form. The function @var{name} is defined | 1810 it were a @code{defun*} form. The function @var{name} is defined |
1839 | 1839 |
1840 Functions defined by @code{flet} may use the full Common Lisp | 1840 Functions defined by @code{flet} may use the full Common Lisp |
1841 argument notation supported by @code{defun*}; also, the function | 1841 argument notation supported by @code{defun*}; also, the function |
1842 body is enclosed in an implicit block as if by @code{defun*}. | 1842 body is enclosed in an implicit block as if by @code{defun*}. |
1843 @xref{Program Structure}. | 1843 @xref{Program Structure}. |
1844 @end deffn | 1844 @end defmac |
1845 | 1845 |
1846 @deffn {Special Operator} labels (bindings@dots{}) forms@dots{} | 1846 @defmac labels (bindings@dots{}) forms@dots{} |
1847 The @code{labels} form is a synonym for @code{flet}. (In Common | 1847 The @code{labels} form is a synonym for @code{flet}. (In Common |
1848 Lisp, @code{labels} and @code{flet} differ in ways that depend on | 1848 Lisp, @code{labels} and @code{flet} differ in ways that depend on |
1849 their lexical scoping; these distinctions vanish in dynamically | 1849 their lexical scoping; these distinctions vanish in dynamically |
1850 scoped Emacs Lisp.) | 1850 scoped Emacs Lisp.) |
1851 @end deffn | 1851 @end defmac |
1852 | 1852 |
1853 @node Macro Bindings, , Function Bindings, Variable Bindings | 1853 @node Macro Bindings, , Function Bindings, Variable Bindings |
1854 @subsection Macro Bindings | 1854 @subsection Macro Bindings |
1855 | 1855 |
1856 @noindent | 1856 @noindent |
1857 These forms create local macros and ``symbol macros.'' | 1857 These forms create local macros and ``symbol macros.'' |
1858 | 1858 |
1859 @deffn {Special Operator} macrolet (bindings@dots{}) forms@dots{} | 1859 @defmac macrolet (bindings@dots{}) forms@dots{} |
1860 This form is analogous to @code{flet}, but for macros instead of | 1860 This form is analogous to @code{flet}, but for macros instead of |
1861 functions. Each @var{binding} is a list of the same form as the | 1861 functions. Each @var{binding} is a list of the same form as the |
1862 arguments to @code{defmacro*} (i.e., a macro name, argument list, | 1862 arguments to @code{defmacro*} (i.e., a macro name, argument list, |
1863 and macro-expander forms). The macro is defined accordingly for | 1863 and macro-expander forms). The macro is defined accordingly for |
1864 use within the body of the @code{macrolet}. | 1864 use within the body of the @code{macrolet}. |
1866 Because of the nature of macros, @code{macrolet} is lexically | 1866 Because of the nature of macros, @code{macrolet} is lexically |
1867 scoped even in Emacs Lisp: The @code{macrolet} binding will | 1867 scoped even in Emacs Lisp: The @code{macrolet} binding will |
1868 affect only calls that appear physically within the body | 1868 affect only calls that appear physically within the body |
1869 @var{forms}, possibly after expansion of other macros in the | 1869 @var{forms}, possibly after expansion of other macros in the |
1870 body. | 1870 body. |
1871 @end deffn | 1871 @end defmac |
1872 | 1872 |
1873 @deffn {Special Operator} symbol-macrolet (bindings@dots{}) forms@dots{} | 1873 @defmac symbol-macrolet (bindings@dots{}) forms@dots{} |
1874 This form creates @dfn{symbol macros}, which are macros that look | 1874 This form creates @dfn{symbol macros}, which are macros that look |
1875 like variable references rather than function calls. Each | 1875 like variable references rather than function calls. Each |
1876 @var{binding} is a list @samp{(@var{var} @var{expansion})}; | 1876 @var{binding} is a list @samp{(@var{var} @var{expansion})}; |
1877 any reference to @var{var} within the body @var{forms} is | 1877 any reference to @var{var} within the body @var{forms} is |
1878 replaced by @var{expansion}. | 1878 replaced by @var{expansion}. |
1933 @end example | 1933 @end example |
1934 | 1934 |
1935 @xref{Loop Facility}, for a description of the @code{loop} macro. | 1935 @xref{Loop Facility}, for a description of the @code{loop} macro. |
1936 This package defines a nonstandard @code{in-ref} loop clause that | 1936 This package defines a nonstandard @code{in-ref} loop clause that |
1937 works much like @code{my-dolist}. | 1937 works much like @code{my-dolist}. |
1938 @end deffn | 1938 @end defmac |
1939 | 1939 |
1940 @node Conditionals, Blocks and Exits, Variable Bindings, Control Structure | 1940 @node Conditionals, Blocks and Exits, Variable Bindings, Control Structure |
1941 @section Conditionals | 1941 @section Conditionals |
1942 | 1942 |
1943 @noindent | 1943 @noindent |
1944 These conditional forms augment Emacs Lisp's simple @code{if}, | 1944 These conditional forms augment Emacs Lisp's simple @code{if}, |
1945 @code{and}, @code{or}, and @code{cond} forms. | 1945 @code{and}, @code{or}, and @code{cond} forms. |
1946 | 1946 |
1947 @deffn {Special Operator} when test forms@dots{} | 1947 @defmac when test forms@dots{} |
1948 This is a variant of @code{if} where there are no ``else'' forms, | 1948 This is a variant of @code{if} where there are no ``else'' forms, |
1949 and possibly several ``then'' forms. In particular, | 1949 and possibly several ``then'' forms. In particular, |
1950 | 1950 |
1951 @example | 1951 @example |
1952 (when @var{test} @var{a} @var{b} @var{c}) | 1952 (when @var{test} @var{a} @var{b} @var{c}) |
1956 is entirely equivalent to | 1956 is entirely equivalent to |
1957 | 1957 |
1958 @example | 1958 @example |
1959 (if @var{test} (progn @var{a} @var{b} @var{c}) nil) | 1959 (if @var{test} (progn @var{a} @var{b} @var{c}) nil) |
1960 @end example | 1960 @end example |
1961 @end deffn | 1961 @end defmac |
1962 | 1962 |
1963 @deffn {Special Operator} unless test forms@dots{} | 1963 @defmac unless test forms@dots{} |
1964 This is a variant of @code{if} where there are no ``then'' forms, | 1964 This is a variant of @code{if} where there are no ``then'' forms, |
1965 and possibly several ``else'' forms: | 1965 and possibly several ``else'' forms: |
1966 | 1966 |
1967 @example | 1967 @example |
1968 (unless @var{test} @var{a} @var{b} @var{c}) | 1968 (unless @var{test} @var{a} @var{b} @var{c}) |
1972 is entirely equivalent to | 1972 is entirely equivalent to |
1973 | 1973 |
1974 @example | 1974 @example |
1975 (when (not @var{test}) @var{a} @var{b} @var{c}) | 1975 (when (not @var{test}) @var{a} @var{b} @var{c}) |
1976 @end example | 1976 @end example |
1977 @end deffn | 1977 @end defmac |
1978 | 1978 |
1979 @deffn {Special Operator} case keyform clause@dots{} | 1979 @defmac case keyform clause@dots{} |
1980 This macro evaluates @var{keyform}, then compares it with the key | 1980 This macro evaluates @var{keyform}, then compares it with the key |
1981 values listed in the various @var{clause}s. Whichever clause matches | 1981 values listed in the various @var{clause}s. Whichever clause matches |
1982 the key is executed; comparison is done by @code{eql}. If no clause | 1982 the key is executed; comparison is done by @code{eql}. If no clause |
1983 matches, the @code{case} form returns @code{nil}. The clauses are | 1983 matches, the @code{case} form returns @code{nil}. The clauses are |
1984 of the form | 1984 of the form |
2008 (?a (do-a-thing)) | 2008 (?a (do-a-thing)) |
2009 (?b (do-b-thing)) | 2009 (?b (do-b-thing)) |
2010 ((?\r ?\n) (do-ret-thing)) | 2010 ((?\r ?\n) (do-ret-thing)) |
2011 (t (do-other-thing))) | 2011 (t (do-other-thing))) |
2012 @end example | 2012 @end example |
2013 @end deffn | 2013 @end defmac |
2014 | 2014 |
2015 @deffn {Special Operator} ecase keyform clause@dots{} | 2015 @defmac ecase keyform clause@dots{} |
2016 This macro is just like @code{case}, except that if the key does | 2016 This macro is just like @code{case}, except that if the key does |
2017 not match any of the clauses, an error is signalled rather than | 2017 not match any of the clauses, an error is signalled rather than |
2018 simply returning @code{nil}. | 2018 simply returning @code{nil}. |
2019 @end deffn | 2019 @end defmac |
2020 | 2020 |
2021 @deffn {Special Operator} typecase keyform clause@dots{} | 2021 @defmac typecase keyform clause@dots{} |
2022 This macro is a version of @code{case} that checks for types | 2022 This macro is a version of @code{case} that checks for types |
2023 rather than values. Each @var{clause} is of the form | 2023 rather than values. Each @var{clause} is of the form |
2024 @samp{(@var{type} @var{body}...)}. @xref{Type Predicates}, | 2024 @samp{(@var{type} @var{body}...)}. @xref{Type Predicates}, |
2025 for a description of type specifiers. For example, | 2025 for a description of type specifiers. For example, |
2026 | 2026 |
2033 @end example | 2033 @end example |
2034 | 2034 |
2035 The type specifier @code{t} matches any type of object; the word | 2035 The type specifier @code{t} matches any type of object; the word |
2036 @code{otherwise} is also allowed. To make one clause match any of | 2036 @code{otherwise} is also allowed. To make one clause match any of |
2037 several types, use an @code{(or ...)} type specifier. | 2037 several types, use an @code{(or ...)} type specifier. |
2038 @end deffn | 2038 @end defmac |
2039 | 2039 |
2040 @deffn {Special Operator} etypecase keyform clause@dots{} | 2040 @defmac etypecase keyform clause@dots{} |
2041 This macro is just like @code{typecase}, except that if the key does | 2041 This macro is just like @code{typecase}, except that if the key does |
2042 not match any of the clauses, an error is signalled rather than | 2042 not match any of the clauses, an error is signalled rather than |
2043 simply returning @code{nil}. | 2043 simply returning @code{nil}. |
2044 @end deffn | 2044 @end defmac |
2045 | 2045 |
2046 @node Blocks and Exits, Iteration, Conditionals, Control Structure | 2046 @node Blocks and Exits, Iteration, Conditionals, Control Structure |
2047 @section Blocks and Exits | 2047 @section Blocks and Exits |
2048 | 2048 |
2049 @noindent | 2049 @noindent |
2052 dynamically scoped. This package actually implements @code{block} | 2052 dynamically scoped. This package actually implements @code{block} |
2053 in terms of @code{catch}; however, the lexical scoping allows the | 2053 in terms of @code{catch}; however, the lexical scoping allows the |
2054 optimizing byte-compiler to omit the costly @code{catch} step if the | 2054 optimizing byte-compiler to omit the costly @code{catch} step if the |
2055 body of the block does not actually @code{return-from} the block. | 2055 body of the block does not actually @code{return-from} the block. |
2056 | 2056 |
2057 @deffn {Special Operator} block name forms@dots{} | 2057 @defmac block name forms@dots{} |
2058 The @var{forms} are evaluated as if by a @code{progn}. However, | 2058 The @var{forms} are evaluated as if by a @code{progn}. However, |
2059 if any of the @var{forms} execute @code{(return-from @var{name})}, | 2059 if any of the @var{forms} execute @code{(return-from @var{name})}, |
2060 they will jump out and return directly from the @code{block} form. | 2060 they will jump out and return directly from the @code{block} form. |
2061 The @code{block} returns the result of the last @var{form} unless | 2061 The @code{block} returns the result of the last @var{form} unless |
2062 a @code{return-from} occurs. | 2062 a @code{return-from} occurs. |
2091 Emacs 19) will optimize away the @code{catch} if the block does | 2091 Emacs 19) will optimize away the @code{catch} if the block does |
2092 not in fact contain any @code{return} or @code{return-from} calls | 2092 not in fact contain any @code{return} or @code{return-from} calls |
2093 that jump to it. This means that @code{do} loops and @code{defun*} | 2093 that jump to it. This means that @code{do} loops and @code{defun*} |
2094 functions which don't use @code{return} don't pay the overhead to | 2094 functions which don't use @code{return} don't pay the overhead to |
2095 support it. | 2095 support it. |
2096 @end deffn | 2096 @end defmac |
2097 | 2097 |
2098 @deffn {Special Operator} return-from name [result] | 2098 @defmac return-from name [result] |
2099 This macro returns from the block named @var{name}, which must be | 2099 This macro returns from the block named @var{name}, which must be |
2100 an (unevaluated) symbol. If a @var{result} form is specified, it | 2100 an (unevaluated) symbol. If a @var{result} form is specified, it |
2101 is evaluated to produce the result returned from the @code{block}. | 2101 is evaluated to produce the result returned from the @code{block}. |
2102 Otherwise, @code{nil} is returned. | 2102 Otherwise, @code{nil} is returned. |
2103 @end deffn | 2103 @end defmac |
2104 | 2104 |
2105 @deffn {Special Operator} return [result] | 2105 @defmac return [result] |
2106 This macro is exactly like @code{(return-from nil @var{result})}. | 2106 This macro is exactly like @code{(return-from nil @var{result})}. |
2107 Common Lisp loops like @code{do} and @code{dolist} implicitly enclose | 2107 Common Lisp loops like @code{do} and @code{dolist} implicitly enclose |
2108 themselves in @code{nil} blocks. | 2108 themselves in @code{nil} blocks. |
2109 @end deffn | 2109 @end defmac |
2110 | 2110 |
2111 @node Iteration, Loop Facility, Blocks and Exits, Control Structure | 2111 @node Iteration, Loop Facility, Blocks and Exits, Control Structure |
2112 @section Iteration | 2112 @section Iteration |
2113 | 2113 |
2114 @noindent | 2114 @noindent |
2115 The macros described here provide more sophisticated, high-level | 2115 The macros described here provide more sophisticated, high-level |
2116 looping constructs to complement Emacs Lisp's basic @code{while} | 2116 looping constructs to complement Emacs Lisp's basic @code{while} |
2117 loop. | 2117 loop. |
2118 | 2118 |
2119 @deffn {Special Operator} loop forms@dots{} | 2119 @defmac loop forms@dots{} |
2120 The @dfn{CL} package supports both the simple, old-style meaning of | 2120 The @dfn{CL} package supports both the simple, old-style meaning of |
2121 @code{loop} and the extremely powerful and flexible feature known as | 2121 @code{loop} and the extremely powerful and flexible feature known as |
2122 the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced | 2122 the @dfn{Loop Facility} or @dfn{Loop Macro}. This more advanced |
2123 facility is discussed in the following section; @pxref{Loop Facility}. | 2123 facility is discussed in the following section; @pxref{Loop Facility}. |
2124 The simple form of @code{loop} is described here. | 2124 The simple form of @code{loop} is described here. |
2142 If any of the expressions are plain symbols, the loop is instead | 2142 If any of the expressions are plain symbols, the loop is instead |
2143 interpreted as a Loop Macro specification as described later. | 2143 interpreted as a Loop Macro specification as described later. |
2144 (This is not a restriction in practice, since a plain symbol | 2144 (This is not a restriction in practice, since a plain symbol |
2145 in the above notation would simply access and throw away the | 2145 in the above notation would simply access and throw away the |
2146 value of a variable.) | 2146 value of a variable.) |
2147 @end deffn | 2147 @end defmac |
2148 | 2148 |
2149 @deffn {Special Operator} do (spec@dots{}) (end-test [result@dots{}]) forms@dots{} | 2149 @defmac do (spec@dots{}) (end-test [result@dots{}]) forms@dots{} |
2150 This macro creates a general iterative loop. Each @var{spec} is | 2150 This macro creates a general iterative loop. Each @var{spec} is |
2151 of the form | 2151 of the form |
2152 | 2152 |
2153 @example | 2153 @example |
2154 (@var{var} [@var{init} [@var{step}]]) | 2154 (@var{var} [@var{init} [@var{step}]]) |
2190 (y bar (cdr y)) | 2190 (y bar (cdr y)) |
2191 (z nil (cons (f (car x) (car y)) z))) | 2191 (z nil (cons (f (car x) (car y)) z))) |
2192 ((or (null x) (null y)) | 2192 ((or (null x) (null y)) |
2193 (nreverse z))) | 2193 (nreverse z))) |
2194 @end example | 2194 @end example |
2195 @end deffn | 2195 @end defmac |
2196 | 2196 |
2197 @deffn {Special Operator} do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{} | 2197 @defmac do* (spec@dots{}) (end-test [result@dots{}]) forms@dots{} |
2198 This is to @code{do} what @code{let*} is to @code{let}. In | 2198 This is to @code{do} what @code{let*} is to @code{let}. In |
2199 particular, the initial values are bound as if by @code{let*} | 2199 particular, the initial values are bound as if by @code{let*} |
2200 rather than @code{let}, and the steps are assigned as if by | 2200 rather than @code{let}, and the steps are assigned as if by |
2201 @code{setq} rather than @code{psetq}. | 2201 @code{setq} rather than @code{psetq}. |
2202 | 2202 |
2210 z) | 2210 z) |
2211 ((or (null xp) (null yp)) | 2211 ((or (null xp) (null yp)) |
2212 (nreverse z)) | 2212 (nreverse z)) |
2213 (push (f x y) z)) | 2213 (push (f x y) z)) |
2214 @end example | 2214 @end example |
2215 @end deffn | 2215 @end defmac |
2216 | 2216 |
2217 @deffn {Special Operator} dolist (var list [result]) forms@dots{} | 2217 @defmac dolist (var list [result]) forms@dots{} |
2218 This is a more specialized loop which iterates across the elements | 2218 This is a more specialized loop which iterates across the elements |
2219 of a list. @var{list} should evaluate to a list; the body @var{forms} | 2219 of a list. @var{list} should evaluate to a list; the body @var{forms} |
2220 are executed with @var{var} bound to each element of the list in | 2220 are executed with @var{var} bound to each element of the list in |
2221 turn. Finally, the @var{result} form (or @code{nil}) is evaluated | 2221 turn. Finally, the @var{result} form (or @code{nil}) is evaluated |
2222 with @var{var} bound to @code{nil} to produce the result returned by | 2222 with @var{var} bound to @code{nil} to produce the result returned by |
2223 the loop. The loop is surrounded by an implicit @code{nil} block. | 2223 the loop. The loop is surrounded by an implicit @code{nil} block. |
2224 @end deffn | 2224 @end defmac |
2225 | 2225 |
2226 @deffn {Special Operator} dotimes (var count [result]) forms@dots{} | 2226 @defmac dotimes (var count [result]) forms@dots{} |
2227 This is a more specialized loop which iterates a specified number | 2227 This is a more specialized loop which iterates a specified number |
2228 of times. The body is executed with @var{var} bound to the integers | 2228 of times. The body is executed with @var{var} bound to the integers |
2229 from zero (inclusive) to @var{count} (exclusive), in turn. Then | 2229 from zero (inclusive) to @var{count} (exclusive), in turn. Then |
2230 the @code{result} form is evaluated with @var{var} bound to the total | 2230 the @code{result} form is evaluated with @var{var} bound to the total |
2231 number of iterations that were done (i.e., @code{(max 0 @var{count})}) | 2231 number of iterations that were done (i.e., @code{(max 0 @var{count})}) |
2232 to get the return value for the loop form. The loop is surrounded | 2232 to get the return value for the loop form. The loop is surrounded |
2233 by an implicit @code{nil} block. | 2233 by an implicit @code{nil} block. |
2234 @end deffn | 2234 @end defmac |
2235 | 2235 |
2236 @deffn {Special Operator} do-symbols (var [obarray [result]]) forms@dots{} | 2236 @defmac do-symbols (var [obarray [result]]) forms@dots{} |
2237 This loop iterates over all interned symbols. If @var{obarray} | 2237 This loop iterates over all interned symbols. If @var{obarray} |
2238 is specified and is not @code{nil}, it loops over all symbols in | 2238 is specified and is not @code{nil}, it loops over all symbols in |
2239 that obarray. For each symbol, the body @var{forms} are evaluated | 2239 that obarray. For each symbol, the body @var{forms} are evaluated |
2240 with @var{var} bound to that symbol. The symbols are visited in | 2240 with @var{var} bound to that symbol. The symbols are visited in |
2241 an unspecified order. Afterward the @var{result} form, if any, | 2241 an unspecified order. Afterward the @var{result} form, if any, |
2242 is evaluated (with @var{var} bound to @code{nil}) to get the return | 2242 is evaluated (with @var{var} bound to @code{nil}) to get the return |
2243 value. The loop is surrounded by an implicit @code{nil} block. | 2243 value. The loop is surrounded by an implicit @code{nil} block. |
2244 @end deffn | 2244 @end defmac |
2245 | 2245 |
2246 @deffn {Special Operator} do-all-symbols (var [result]) forms@dots{} | 2246 @defmac do-all-symbols (var [result]) forms@dots{} |
2247 This is identical to @code{do-symbols} except that the @var{obarray} | 2247 This is identical to @code{do-symbols} except that the @var{obarray} |
2248 argument is omitted; it always iterates over the default obarray. | 2248 argument is omitted; it always iterates over the default obarray. |
2249 @end deffn | 2249 @end defmac |
2250 | 2250 |
2251 @xref{Mapping over Sequences}, for some more functions for | 2251 @xref{Mapping over Sequences}, for some more functions for |
2252 iterating over vectors or lists. | 2252 iterating over vectors or lists. |
2253 | 2253 |
2254 @node Loop Facility, Multiple Values, Iteration, Control Structure | 2254 @node Loop Facility, Multiple Values, Iteration, Control Structure |
2284 | 2284 |
2285 Since @code{loop} is a macro, all parsing of the loop language | 2285 Since @code{loop} is a macro, all parsing of the loop language |
2286 takes place at byte-compile time; compiled @code{loop}s are just | 2286 takes place at byte-compile time; compiled @code{loop}s are just |
2287 as efficient as the equivalent @code{while} loops written longhand. | 2287 as efficient as the equivalent @code{while} loops written longhand. |
2288 | 2288 |
2289 @deffn {Special Operator} loop clauses@dots{} | 2289 @defmac loop clauses@dots{} |
2290 A loop construct consists of a series of @var{clause}s, each | 2290 A loop construct consists of a series of @var{clause}s, each |
2291 introduced by a symbol like @code{for} or @code{do}. Clauses | 2291 introduced by a symbol like @code{for} or @code{do}. Clauses |
2292 are simply strung together in the argument list of @code{loop}, | 2292 are simply strung together in the argument list of @code{loop}, |
2293 with minimal extra parentheses. The various types of clauses | 2293 with minimal extra parentheses. The various types of clauses |
2294 specify initializations, such as the binding of temporary | 2294 specify initializations, such as the binding of temporary |
2323 @code{collect}, an end-test clause like @code{always}, or an | 2323 @code{collect}, an end-test clause like @code{always}, or an |
2324 explicit @code{return} clause to jump out of the implicit block. | 2324 explicit @code{return} clause to jump out of the implicit block. |
2325 (Because the loop body is enclosed in an implicit block, you can | 2325 (Because the loop body is enclosed in an implicit block, you can |
2326 also use regular Lisp @code{return} or @code{return-from} to | 2326 also use regular Lisp @code{return} or @code{return-from} to |
2327 break out of the loop.) | 2327 break out of the loop.) |
2328 @end deffn | 2328 @end defmac |
2329 | 2329 |
2330 The following sections give some examples of the Loop Macro in | 2330 The following sections give some examples of the Loop Macro in |
2331 action, and describe the particular loop clauses in great detail. | 2331 action, and describe the particular loop clauses in great detail. |
2332 Consult the second edition of Steele's @dfn{Common Lisp, the Language}, | 2332 Consult the second edition of Steele's @dfn{Common Lisp, the Language}, |
2333 for additional discussion and examples of the @code{loop} macro. | 2333 for additional discussion and examples of the @code{loop} macro. |
3001 @xref{Argument Lists}. | 3001 @xref{Argument Lists}. |
3002 | 3002 |
3003 Destructuring is made available to the user by way of the | 3003 Destructuring is made available to the user by way of the |
3004 following macro: | 3004 following macro: |
3005 | 3005 |
3006 @deffn {Special Operator} destructuring-bind arglist expr forms@dots{} | 3006 @defmac destructuring-bind arglist expr forms@dots{} |
3007 This macro expands to code which executes @var{forms}, with | 3007 This macro expands to code which executes @var{forms}, with |
3008 the variables in @var{arglist} bound to the list of values | 3008 the variables in @var{arglist} bound to the list of values |
3009 returned by @var{expr}. The @var{arglist} can include all | 3009 returned by @var{expr}. The @var{arglist} can include all |
3010 the features allowed for @code{defmacro} argument lists, | 3010 the features allowed for @code{defmacro} argument lists, |
3011 including destructuring. (The @code{&environment} keyword | 3011 including destructuring. (The @code{&environment} keyword |
3012 is not allowed.) The macro expansion will signal an error | 3012 is not allowed.) The macro expansion will signal an error |
3013 if @var{expr} returns a list of the wrong number of arguments | 3013 if @var{expr} returns a list of the wrong number of arguments |
3014 or with incorrect keyword arguments. | 3014 or with incorrect keyword arguments. |
3015 @end deffn | 3015 @end defmac |
3016 | 3016 |
3017 This package also includes the Common Lisp @code{define-compiler-macro} | 3017 This package also includes the Common Lisp @code{define-compiler-macro} |
3018 facility, which allows you to define compile-time expansions and | 3018 facility, which allows you to define compile-time expansions and |
3019 optimizations for your functions. | 3019 optimizations for your functions. |
3020 | 3020 |
3021 @deffn {Special Operator} define-compiler-macro name arglist forms@dots{} | 3021 @defmac define-compiler-macro name arglist forms@dots{} |
3022 This form is similar to @code{defmacro}, except that it only expands | 3022 This form is similar to @code{defmacro}, except that it only expands |
3023 calls to @var{name} at compile-time; calls processed by the Lisp | 3023 calls to @var{name} at compile-time; calls processed by the Lisp |
3024 interpreter are not expanded, nor are they expanded by the | 3024 interpreter are not expanded, nor are they expanded by the |
3025 @code{macroexpand} function. | 3025 @code{macroexpand} function. |
3026 | 3026 |
3050 is a non-floating-point constant; if @var{a} is anything else, or | 3050 is a non-floating-point constant; if @var{a} is anything else, or |
3051 if there are any keyword arguments in the call, then the original | 3051 if there are any keyword arguments in the call, then the original |
3052 @code{member*} call is left intact. (The actual compiler macro | 3052 @code{member*} call is left intact. (The actual compiler macro |
3053 for @code{member*} optimizes a number of other cases, including | 3053 for @code{member*} optimizes a number of other cases, including |
3054 common @code{:test} predicates.) | 3054 common @code{:test} predicates.) |
3055 @end deffn | 3055 @end defmac |
3056 | 3056 |
3057 @defun compiler-macroexpand form | 3057 @defun compiler-macroexpand form |
3058 This function is analogous to @code{macroexpand}, except that it | 3058 This function is analogous to @code{macroexpand}, except that it |
3059 expands compiler macros rather than regular macros. It returns | 3059 expands compiler macros rather than regular macros. It returns |
3060 @var{form} unchanged if it is not a call to a function for which | 3060 @var{form} unchanged if it is not a call to a function for which |
3092 This function records a ``global'' declaration specified by | 3092 This function records a ``global'' declaration specified by |
3093 @var{decl-spec}. Since @code{proclaim} is a function, @var{decl-spec} | 3093 @var{decl-spec}. Since @code{proclaim} is a function, @var{decl-spec} |
3094 is evaluated and thus should normally be quoted. | 3094 is evaluated and thus should normally be quoted. |
3095 @end defun | 3095 @end defun |
3096 | 3096 |
3097 @deffn {Special Operator} declaim decl-specs@dots{} | 3097 @defmac declaim decl-specs@dots{} |
3098 This macro is like @code{proclaim}, except that it takes any number | 3098 This macro is like @code{proclaim}, except that it takes any number |
3099 of @var{decl-spec} arguments, and the arguments are unevaluated and | 3099 of @var{decl-spec} arguments, and the arguments are unevaluated and |
3100 unquoted. The @code{declaim} macro also puts an @code{(eval-when | 3100 unquoted. The @code{declaim} macro also puts an @code{(eval-when |
3101 (compile load eval) ...)} around the declarations so that they will | 3101 (compile load eval) ...)} around the declarations so that they will |
3102 be registered at compile-time as well as at run-time. (This is vital, | 3102 be registered at compile-time as well as at run-time. (This is vital, |
3103 since normally the declarations are meant to influence the way the | 3103 since normally the declarations are meant to influence the way the |
3104 compiler treats the rest of the file that contains the @code{declaim} | 3104 compiler treats the rest of the file that contains the @code{declaim} |
3105 form.) | 3105 form.) |
3106 @end deffn | 3106 @end defmac |
3107 | 3107 |
3108 @deffn {Special Operator} declare decl-specs@dots{} | 3108 @defmac declare decl-specs@dots{} |
3109 This macro is used to make declarations within functions and other | 3109 This macro is used to make declarations within functions and other |
3110 code. Common Lisp allows declarations in various locations, generally | 3110 code. Common Lisp allows declarations in various locations, generally |
3111 at the beginning of any of the many ``implicit @code{progn}s'' | 3111 at the beginning of any of the many ``implicit @code{progn}s'' |
3112 throughout Lisp syntax, such as function bodies, @code{let} bodies, | 3112 throughout Lisp syntax, such as function bodies, @code{let} bodies, |
3113 etc. Currently the only declaration understood by @code{declare} | 3113 etc. Currently the only declaration understood by @code{declare} |
3114 is @code{special}. | 3114 is @code{special}. |
3115 @end deffn | 3115 @end defmac |
3116 | 3116 |
3117 @deffn {Special Operator} locally declarations@dots{} forms@dots{} | 3117 @defmac locally declarations@dots{} forms@dots{} |
3118 In this package, @code{locally} is no different from @code{progn}. | 3118 In this package, @code{locally} is no different from @code{progn}. |
3119 @end deffn | 3119 @end defmac |
3120 | 3120 |
3121 @deffn {Special Operator} the type form | 3121 @defmac the type form |
3122 Type information provided by @code{the} is ignored in this package; | 3122 Type information provided by @code{the} is ignored in this package; |
3123 in other words, @code{(the @var{type} @var{form})} is equivalent | 3123 in other words, @code{(the @var{type} @var{form})} is equivalent |
3124 to @var{form}. Future versions of the optimizing byte-compiler may | 3124 to @var{form}. Future versions of the optimizing byte-compiler may |
3125 make use of this information. | 3125 make use of this information. |
3126 | 3126 |
3129 unless it knows whether the sequence will be a list or an array ahead | 3129 unless it knows whether the sequence will be a list or an array ahead |
3130 of time. With @code{(mapcar 'car (the vector foo))}, a future | 3130 of time. With @code{(mapcar 'car (the vector foo))}, a future |
3131 compiler would have enough information to expand the loop in-line. | 3131 compiler would have enough information to expand the loop in-line. |
3132 For now, Emacs Lisp will treat the above code as exactly equivalent | 3132 For now, Emacs Lisp will treat the above code as exactly equivalent |
3133 to @code{(mapcar 'car foo)}. | 3133 to @code{(mapcar 'car foo)}. |
3134 @end deffn | 3134 @end defmac |
3135 | 3135 |
3136 Each @var{decl-spec} in a @code{proclaim}, @code{declaim}, or | 3136 Each @var{decl-spec} in a @code{proclaim}, @code{declaim}, or |
3137 @code{declare} should be a list beginning with a symbol that says | 3137 @code{declare} should be a list beginning with a symbol that says |
3138 what kind of declaration it is. This package currently understands | 3138 what kind of declaration it is. This package currently understands |
3139 @code{special}, @code{inline}, @code{notinline}, @code{optimize}, | 3139 @code{special}, @code{inline}, @code{notinline}, @code{optimize}, |
3311 When not used as a @code{setf} form, @code{getf} is just a regular | 3311 When not used as a @code{setf} form, @code{getf} is just a regular |
3312 function and its @var{place} argument can actually be any Lisp | 3312 function and its @var{place} argument can actually be any Lisp |
3313 expression. | 3313 expression. |
3314 @end defun | 3314 @end defun |
3315 | 3315 |
3316 @deffn {Special Operator} remf place property | 3316 @defmac remf place property |
3317 This macro removes the property-value pair for @var{property} from | 3317 This macro removes the property-value pair for @var{property} from |
3318 the property list stored at @var{place}, which is any @code{setf}-able | 3318 the property list stored at @var{place}, which is any @code{setf}-able |
3319 place expression. It returns true if the property was found. Note | 3319 place expression. It returns true if the property was found. Note |
3320 that if @var{property} happens to be first on the list, this will | 3320 that if @var{property} happens to be first on the list, this will |
3321 effectively do a @code{(setf @var{place} (cddr @var{place}))}, | 3321 effectively do a @code{(setf @var{place} (cddr @var{place}))}, |
3322 whereas if it occurs later, this simply uses @code{setcdr} to splice | 3322 whereas if it occurs later, this simply uses @code{setcdr} to splice |
3323 out the property and value cells. | 3323 out the property and value cells. |
3324 @end deffn | 3324 @end defmac |
3325 | 3325 |
3326 @iftex | 3326 @iftex |
3327 @secno=2 | 3327 @secno=2 |
3328 @end iftex | 3328 @end iftex |
3329 | 3329 |
4675 from all existing Lisp types. Since the underlying Emacs Lisp | 4675 from all existing Lisp types. Since the underlying Emacs Lisp |
4676 system provides no way to create new distinct types, this package | 4676 system provides no way to create new distinct types, this package |
4677 implements structures as vectors (or lists upon request) with a | 4677 implements structures as vectors (or lists upon request) with a |
4678 special ``tag'' symbol to identify them. | 4678 special ``tag'' symbol to identify them. |
4679 | 4679 |
4680 @deffn {Special Operator} defstruct name slots@dots{} | 4680 @defmac defstruct name slots@dots{} |
4681 The @code{defstruct} form defines a new structure type called | 4681 The @code{defstruct} form defines a new structure type called |
4682 @var{name}, with the specified @var{slots}. (The @var{slots} | 4682 @var{name}, with the specified @var{slots}. (The @var{slots} |
4683 may begin with a string which documents the structure type.) | 4683 may begin with a string which documents the structure type.) |
4684 In the simplest case, @var{name} and each of the @var{slots} | 4684 In the simplest case, @var{name} and each of the @var{slots} |
4685 are symbols. For example, | 4685 are symbols. For example, |
4982 with @code{nil} by the constructors and ignored otherwise. If | 4982 with @code{nil} by the constructors and ignored otherwise. If |
4983 the type @code{:include}s another type, then @code{:initial-offset} | 4983 the type @code{:include}s another type, then @code{:initial-offset} |
4984 specifies a number of slots to be skipped between the last slot | 4984 specifies a number of slots to be skipped between the last slot |
4985 of the included type and the first new slot. | 4985 of the included type and the first new slot. |
4986 @end table | 4986 @end table |
4987 @end deffn | 4987 @end defmac |
4988 | 4988 |
4989 Except as noted, the @code{defstruct} facility of this package is | 4989 Except as noted, the @code{defstruct} facility of this package is |
4990 entirely compatible with that of Common Lisp. | 4990 entirely compatible with that of Common Lisp. |
4991 | 4991 |
4992 @iftex | 4992 @iftex |
5005 If the optimization property @code{speed} has been set to 3, and | 5005 If the optimization property @code{speed} has been set to 3, and |
5006 @code{safety} is less than 3, then the byte-compiler will optimize | 5006 @code{safety} is less than 3, then the byte-compiler will optimize |
5007 away the following assertions. Because assertions might be optimized | 5007 away the following assertions. Because assertions might be optimized |
5008 away, it is a bad idea for them to include side-effects. | 5008 away, it is a bad idea for them to include side-effects. |
5009 | 5009 |
5010 @deffn {Special Operator} assert test-form [show-args string args@dots{}] | 5010 @defmac assert test-form [show-args string args@dots{}] |
5011 This form verifies that @var{test-form} is true (i.e., evaluates to | 5011 This form verifies that @var{test-form} is true (i.e., evaluates to |
5012 a non-@code{nil} value). If so, it returns @code{nil}. If the test | 5012 a non-@code{nil} value). If so, it returns @code{nil}. If the test |
5013 is not satisfied, @code{assert} signals an error. | 5013 is not satisfied, @code{assert} signals an error. |
5014 | 5014 |
5015 A default error message will be supplied which includes @var{test-form}. | 5015 A default error message will be supplied which includes @var{test-form}. |
5028 | 5028 |
5029 This usage of @var{show-args} is a change to Common Lisp. In | 5029 This usage of @var{show-args} is a change to Common Lisp. In |
5030 true Common Lisp, the second argument gives a list of @var{places} | 5030 true Common Lisp, the second argument gives a list of @var{places} |
5031 which can be @code{setf}'d by the user before continuing from the | 5031 which can be @code{setf}'d by the user before continuing from the |
5032 error. | 5032 error. |
5033 @end deffn | 5033 @end defmac |
5034 | 5034 |
5035 @deffn {Special Operator} check-type place type &optional string | 5035 @defmac check-type place type &optional string |
5036 This form verifies that @var{place} evaluates to a value of type | 5036 This form verifies that @var{place} evaluates to a value of type |
5037 @var{type}. If so, it returns @code{nil}. If not, @code{check-type} | 5037 @var{type}. If so, it returns @code{nil}. If not, @code{check-type} |
5038 signals a continuable @code{wrong-type-argument} error. The default | 5038 signals a continuable @code{wrong-type-argument} error. The default |
5039 error message lists the erroneous value along with @var{type} and | 5039 error message lists the erroneous value along with @var{type} and |
5040 @var{place} themselves. If @var{string} is specified, it is included in | 5040 @var{place} themselves. If @var{string} is specified, it is included in |
5049 | 5049 |
5050 Note that as in Common Lisp, the first argument to @code{check-type} | 5050 Note that as in Common Lisp, the first argument to @code{check-type} |
5051 should be a @var{place} suitable for use by @code{setf}, because | 5051 should be a @var{place} suitable for use by @code{setf}, because |
5052 @code{check-type} signals a continuable error that allows the user to | 5052 @code{check-type} signals a continuable error that allows the user to |
5053 modify @var{place}, most simply by returning a value from the debugger. | 5053 modify @var{place}, most simply by returning a value from the debugger. |
5054 @end deffn | 5054 @end defmac |
5055 | 5055 |
5056 The following error-related macro is also defined: | 5056 The following error-related macro is also defined: |
5057 | 5057 |
5058 @deffn {Special Operator} ignore-errors forms@dots{} | 5058 @defmac ignore-errors forms@dots{} |
5059 This executes @var{forms} exactly like a @code{progn}, except that | 5059 This executes @var{forms} exactly like a @code{progn}, except that |
5060 errors are ignored during the @var{forms}. More precisely, if | 5060 errors are ignored during the @var{forms}. More precisely, if |
5061 an error is signalled then @code{ignore-errors} immediately | 5061 an error is signalled then @code{ignore-errors} immediately |
5062 aborts execution of the @var{forms} and returns @code{nil}. | 5062 aborts execution of the @var{forms} and returns @code{nil}. |
5063 If the @var{forms} complete successfully, @code{ignore-errors} | 5063 If the @var{forms} complete successfully, @code{ignore-errors} |
5064 returns the result of the last @var{form}. | 5064 returns the result of the last @var{form}. |
5065 @end deffn | 5065 @end defmac |
5066 | 5066 |
5067 @node Efficiency Concerns, Common Lisp Compatibility, Assertions, Top | 5067 @node Efficiency Concerns, Common Lisp Compatibility, Assertions, Top |
5068 @appendix Efficiency Concerns | 5068 @appendix Efficiency Concerns |
5069 | 5069 |
5070 @appendixsec Macros | 5070 @appendixsec Macros |