Mercurial > hg > xemacs-beta
comparison man/lispref/control.texi @ 4905:755ae5b97edb
Change "special form" to "special operator" in our sources.
Add a compatible function alias, and the relevant manual index entries.
src/ChangeLog addition:
2010-01-31 Aidan Kehoe <kehoea@parhasard.net>
* symbols.c (Fspecial_operator_p, syms_of_symbols):
* eval.c (print_subr, Finteractive_p, Ffuncall)
(Ffunction_min_args, Ffunction_max_args, vars_of_eval):
* editfns.c:
* data.c (Fsubr_max_args):
* doc.c (Fbuilt_in_symbol_file):
Change "special form" to "special operator" in our sources.
man/ChangeLog addition:
2010-01-31 Aidan Kehoe <kehoea@parhasard.net>
* xemacs/programs.texi (Defuns):
* lispref/variables.texi (Local Variables, Defining Variables)
(Setting Variables, Default Value):
* lispref/symbols.texi (Definitions):
* lispref/searching.texi (Saving Match Data):
* lispref/positions.texi (Excursions, Narrowing):
* lispref/objects.texi (Primitive Function Type):
* lispref/macros.texi (Defining Macros, Backquote):
* lispref/lispref.texi (Top):
* lispref/intro.texi (A Sample Function Description):
* lispref/help.texi (Help Functions):
* lispref/functions.texi (What Is a Function, Simple Lambda)
(Defining Functions, Calling Functions, Anonymous Functions):
* lispref/frames.texi (Input Focus):
* lispref/eval.texi (Forms, Function Indirection)
(Special Operators, Quoting):
* lispref/edebug-inc.texi (Instrumenting)
(Specification Examples):
* lispref/debugging.texi (Internals of Debugger):
* lispref/control.texi (Control Structures, Sequencing):
(Conditionals, Combining Conditions, Iteration):
(Catch and Throw, Handling Errors):
* lispref/commands.texi (Defining Commands, Using Interactive):
Terminology change; special operator -> special form.
Don't attempt to change this in texinfo.texi or cl.texi, which use
macros I don't understand.
* lispref/macros.texi (Defining Macros): Give an anonymous macro
example here.
* lispref/positions.texi (Excursions):
Correct some documentation that called a couple of macros special
forms.
* lispref/searching.texi (Saving Match Data):
Drop some documentation of how to write code that works with Emacs
18.
* lispref/specifiers.texi (Adding Specifications):
Correct this; #'let-specifier is a macro, not a special operator.
* lispref/windows.texi (Window Configurations)
(Selecting Windows):
Correct this, #'save-selected-window and #'save-window-excursion
are macros, not special operators.
lisp/ChangeLog addition:
2010-01-31 Aidan Kehoe <kehoea@parhasard.net>
* obsolete.el:
* loadhist.el (symbol-file):
* help.el (describe-function-1):
* bytecomp.el: (byte-compile-save-current-buffer):
* byte-optimize.el (byte-optimize-form-code-walker):
* subr.el (subr-arity):
Change "special form" to "special operator" in these files, it's
the more logical term.
* subr.el (special-form-p): Provide this alias for
#'special-operator-p.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sun, 31 Jan 2010 20:28:01 +0000 |
parents | 13a418960a88 |
children | 62b9ef1ed4ac |
comparison
equal
deleted
inserted
replaced
4904:e91e3e353805 | 4905:755ae5b97edb |
---|---|
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | 3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. |
4 @c See the file lispref.texi for copying conditions. | 4 @c See the file lispref.texi for copying conditions. |
5 @setfilename ../../info/control.info | 5 @setfilename ../../info/control.info |
6 @node Control Structures, Variables, Evaluation, Top | 6 @node Control Structures, Variables, Evaluation, Top |
7 @chapter Control Structures | 7 @chapter Control Structures |
8 @cindex special forms for control structures | 8 @cindex special operators for control structures |
9 @cindex control structures | 9 @cindex control structures |
10 | 10 |
11 A Lisp program consists of expressions or @dfn{forms} (@pxref{Forms}). | 11 A Lisp program consists of expressions or @dfn{forms} (@pxref{Forms}). |
12 We control the order of execution of the forms by enclosing them in | 12 We control the order of execution of the forms by enclosing them in |
13 @dfn{control structures}. Control structures are special forms which | 13 @dfn{control structures}. Control structures are special operators which |
14 control when, whether, or how many times to execute the forms they | 14 control when, whether, or how many times to execute the subforms of |
15 contain. | 15 their containing forms. |
16 | 16 |
17 The simplest order of execution is sequential execution: first form | 17 The simplest order of execution is sequential execution: first form |
18 @var{a}, then form @var{b}, and so on. This is what happens when you | 18 @var{a}, then form @var{b}, and so on. This is what happens when you |
19 write several forms in succession in the body of a function, or at top | 19 write several forms in succession in the body of a function, or at top |
20 level in a file of Lisp code---the forms are executed in the order | 20 level in a file of Lisp code---the forms are executed in the order |
27 than sequential. | 27 than sequential. |
28 | 28 |
29 XEmacs Lisp provides several kinds of control structure, including | 29 XEmacs Lisp provides several kinds of control structure, including |
30 other varieties of sequencing, conditionals, iteration, and (controlled) | 30 other varieties of sequencing, conditionals, iteration, and (controlled) |
31 jumps---all discussed below. The built-in control structures are | 31 jumps---all discussed below. The built-in control structures are |
32 special forms since their subforms are not necessarily evaluated or not | 32 special operators since their enclosing forms' subforms are not |
33 evaluated sequentially. You can use macros to define your own control | 33 necessarily evaluated or not evaluated sequentially. You can use macros |
34 structure constructs (@pxref{Macros}). | 34 to define your own control structure constructs (@pxref{Macros}). |
35 | 35 |
36 @menu | 36 @menu |
37 * Sequencing:: Evaluation in textual order. | 37 * Sequencing:: Evaluation in textual order. |
38 * Conditionals:: @code{if}, @code{cond}. | 38 * Conditionals:: @code{if}, @code{cond}. |
39 * Combining Conditions:: @code{and}, @code{or}, @code{not}. | 39 * Combining Conditions:: @code{and}, @code{or}, @code{not}. |
75 As a result, @code{progn} is not used as often as it used to be. It is | 75 As a result, @code{progn} is not used as often as it used to be. It is |
76 needed now most often inside an @code{unwind-protect}, @code{and}, | 76 needed now most often inside an @code{unwind-protect}, @code{and}, |
77 @code{or}, or in the @var{then}-part of an @code{if}. | 77 @code{or}, or in the @var{then}-part of an @code{if}. |
78 | 78 |
79 @defspec progn forms@dots{} | 79 @defspec progn forms@dots{} |
80 This special form evaluates all of the @var{forms}, in textual | 80 This special operator evaluates all of the @var{forms}, in textual |
81 order, returning the result of the final form. | 81 order, returning the result of the final form. |
82 | 82 |
83 @example | 83 @example |
84 @group | 84 @group |
85 (progn (print "The first form") | 85 (progn (print "The first form") |
95 | 95 |
96 Two other control constructs likewise evaluate a series of forms but return | 96 Two other control constructs likewise evaluate a series of forms but return |
97 a different value: | 97 a different value: |
98 | 98 |
99 @defspec prog1 form1 forms@dots{} | 99 @defspec prog1 form1 forms@dots{} |
100 This special form evaluates @var{form1} and all of the @var{forms}, in | 100 This special operator evaluates @var{form1} and all of the @var{forms}, in |
101 textual order, returning the result of @var{form1}. | 101 textual order, returning the result of @var{form1}. |
102 | 102 |
103 @example | 103 @example |
104 @group | 104 @group |
105 (prog1 (print "The first form") | 105 (prog1 (print "The first form") |
119 (prog1 (car x) (setq x (cdr x))) | 119 (prog1 (car x) (setq x (cdr x))) |
120 @end example | 120 @end example |
121 @end defspec | 121 @end defspec |
122 | 122 |
123 @defspec prog2 form1 form2 forms@dots{} | 123 @defspec prog2 form1 form2 forms@dots{} |
124 This special form evaluates @var{form1}, @var{form2}, and all of the | 124 This special operator evaluates @var{form1}, @var{form2}, and all of the |
125 following @var{forms}, in textual order, returning the result of | 125 following @var{forms}, in textual order, returning the result of |
126 @var{form2}. | 126 @var{form2}. |
127 | 127 |
128 @example | 128 @example |
129 @group | 129 @group |
155 an example of an implicit @code{progn}. @xref{Sequencing}.) | 155 an example of an implicit @code{progn}. @xref{Sequencing}.) |
156 | 156 |
157 If @var{condition} has the value @code{nil}, and no @var{else-forms} are | 157 If @var{condition} has the value @code{nil}, and no @var{else-forms} are |
158 given, @code{if} returns @code{nil}. | 158 given, @code{if} returns @code{nil}. |
159 | 159 |
160 @code{if} is a special form because the branch that is not selected is | 160 @code{if} is a special operator because the branch that is not selected is |
161 never evaluated---it is ignored. Thus, in the example below, | 161 never evaluated---it is ignored. Thus, in the example below, |
162 @code{true} is not printed because @code{print} is never called. | 162 @code{true} is not printed because @code{print} is never called. |
163 | 163 |
164 @example | 164 @example |
165 @group | 165 @group |
267 The function @code{not} is identical to @code{null}, and we recommend | 267 The function @code{not} is identical to @code{null}, and we recommend |
268 using the name @code{null} if you are testing for an empty list. | 268 using the name @code{null} if you are testing for an empty list. |
269 @end defun | 269 @end defun |
270 | 270 |
271 @defspec and conditions@dots{} | 271 @defspec and conditions@dots{} |
272 The @code{and} special form tests whether all the @var{conditions} are | 272 The @code{and} special operator tests whether all the @var{conditions} are |
273 true. It works by evaluating the @var{conditions} one by one in the | 273 true. It works by evaluating the @var{conditions} one by one in the |
274 order written. | 274 order written. |
275 | 275 |
276 If any of the @var{conditions} evaluates to @code{nil}, then the result | 276 If any of the @var{conditions} evaluates to @code{nil}, then the result |
277 of the @code{and} must be @code{nil} regardless of the remaining | 277 of the @code{and} must be @code{nil} regardless of the remaining |
321 @end group | 321 @end group |
322 @end example | 322 @end example |
323 @end defspec | 323 @end defspec |
324 | 324 |
325 @defspec or conditions@dots{} | 325 @defspec or conditions@dots{} |
326 The @code{or} special form tests whether at least one of the | 326 The @code{or} special operator tests whether at least one of the |
327 @var{conditions} is true. It works by evaluating all the | 327 @var{conditions} is true. It works by evaluating all the |
328 @var{conditions} one by one in the order written. | 328 @var{conditions} one by one in the order written. |
329 | 329 |
330 If any of the @var{conditions} evaluates to a non-@code{nil} value, then | 330 If any of the @var{conditions} evaluates to a non-@code{nil} value, then |
331 the result of the @code{or} must be non-@code{nil}; so @code{or} returns | 331 the result of the @code{or} must be non-@code{nil}; so @code{or} returns |
377 @cindex recursion | 377 @cindex recursion |
378 | 378 |
379 Iteration means executing part of a program repetitively. For | 379 Iteration means executing part of a program repetitively. For |
380 example, you might want to repeat some computation once for each element | 380 example, you might want to repeat some computation once for each element |
381 of a list, or once for each integer from 0 to @var{n}. You can do this | 381 of a list, or once for each integer from 0 to @var{n}. You can do this |
382 in XEmacs Lisp with the special form @code{while}: | 382 in XEmacs Lisp with the special operator @code{while}: |
383 | 383 |
384 @defspec while condition forms@dots{} | 384 @defspec while condition forms@dots{} |
385 @code{while} first evaluates @var{condition}. If the result is | 385 @code{while} first evaluates @var{condition}. If the result is |
386 non-@code{nil}, it evaluates @var{forms} in textual order. Then it | 386 non-@code{nil}, it evaluates @var{forms} in textual order. Then it |
387 reevaluates @var{condition}, and if the result is non-@code{nil}, it | 387 reevaluates @var{condition}, and if the result is non-@code{nil}, it |
486 (@pxref{Local Variables}). Likewise, @code{throw} restores the buffer | 486 (@pxref{Local Variables}). Likewise, @code{throw} restores the buffer |
487 and position saved by @code{save-excursion} (@pxref{Excursions}), and | 487 and position saved by @code{save-excursion} (@pxref{Excursions}), and |
488 the narrowing status saved by @code{save-restriction} and the window | 488 the narrowing status saved by @code{save-restriction} and the window |
489 selection saved by @code{save-window-excursion} (@pxref{Window | 489 selection saved by @code{save-window-excursion} (@pxref{Window |
490 Configurations}). It also runs any cleanups established with the | 490 Configurations}). It also runs any cleanups established with the |
491 @code{unwind-protect} special form when it exits that form | 491 @code{unwind-protect} special operator when it exits that form |
492 (@pxref{Cleanups}). | 492 (@pxref{Cleanups}). |
493 | 493 |
494 The @code{throw} need not appear lexically within the @code{catch} | 494 The @code{throw} need not appear lexically within the @code{catch} |
495 that it jumps to. It can equally well be called from another function | 495 that it jumps to. It can equally well be called from another function |
496 called within the @code{catch}. As long as the @code{throw} takes place | 496 called within the @code{catch}. As long as the @code{throw} takes place |
955 @cindex handling errors | 955 @cindex handling errors |
956 | 956 |
957 The usual effect of signaling an error is to terminate the command | 957 The usual effect of signaling an error is to terminate the command |
958 that is running and return immediately to the XEmacs editor command loop. | 958 that is running and return immediately to the XEmacs editor command loop. |
959 You can arrange to trap errors occurring in a part of your program by | 959 You can arrange to trap errors occurring in a part of your program by |
960 establishing an error handler, with the special form | 960 establishing an error handler, with the special operator |
961 @code{condition-case}. A simple example looks like this: | 961 @code{condition-case}. A simple example looks like this: |
962 | 962 |
963 @example | 963 @example |
964 @group | 964 @group |
965 (condition-case nil | 965 (condition-case nil |
1027 cannot be caught by a @code{catch}, and a @code{throw} cannot be handled | 1027 cannot be caught by a @code{catch}, and a @code{throw} cannot be handled |
1028 by an error handler (though using @code{throw} when there is no suitable | 1028 by an error handler (though using @code{throw} when there is no suitable |
1029 @code{catch} signals an error that can be handled). | 1029 @code{catch} signals an error that can be handled). |
1030 | 1030 |
1031 @defspec condition-case var protected-form handlers@dots{} | 1031 @defspec condition-case var protected-form handlers@dots{} |
1032 This special form establishes the error handlers @var{handlers} around | 1032 This special operator establishes the error handlers @var{handlers} around |
1033 the execution of @var{protected-form}. If @var{protected-form} executes | 1033 the execution of @var{protected-form}. If @var{protected-form} executes |
1034 without error, the value it returns becomes the value of the | 1034 without error, the value it returns becomes the value of the |
1035 @code{condition-case} form; in this case, the @code{condition-case} has | 1035 @code{condition-case} form; in this case, the @code{condition-case} has |
1036 no effect. The @code{condition-case} form makes a difference when an | 1036 no effect. The @code{condition-case} form makes a difference when an |
1037 error occurs during @var{protected-form}. | 1037 error occurs during @var{protected-form}. |