aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-01-09 07:58:14 +0000
committerRichard M. Stallman1997-01-09 07:58:14 +0000
commit26eb64a99c5bc536ba4b2e27ad2fac3d80447da1 (patch)
tree707e0ba2fa850999d32eecae8799438e851f2da3
parent5943195a9c0fe1577c09de391640d58ed6060485 (diff)
downloademacs-26eb64a99c5bc536ba4b2e27ad2fac3d80447da1.tar.gz
emacs-26eb64a99c5bc536ba4b2e27ad2fac3d80447da1.zip
Add when and unless.
-rw-r--r--lispref/control.texi37
1 files changed, 35 insertions, 2 deletions
diff --git a/lispref/control.texi b/lispref/control.texi
index 4973599d877..4d01661a9a1 100644
--- a/lispref/control.texi
+++ b/lispref/control.texi
@@ -143,8 +143,9 @@ following @var{forms}, in textual order, returning the result of
143@cindex conditional evaluation 143@cindex conditional evaluation
144 144
145 Conditional control structures choose among alternatives. Emacs Lisp 145 Conditional control structures choose among alternatives. Emacs Lisp
146has two conditional forms: @code{if}, which is much the same as in other 146has four conditional forms: @code{if}, which is much the same as in
147languages, and @code{cond}, which is a generalized case statement. 147other languages; @code{when} and @code{unless}, which are variants of
148@code{if}; and @code{cond}, which is a generalized case statement.
148 149
149@defspec if condition then-form else-forms@dots{} 150@defspec if condition then-form else-forms@dots{}
150@code{if} chooses between the @var{then-form} and the @var{else-forms} 151@code{if} chooses between the @var{then-form} and the @var{else-forms}
@@ -171,6 +172,38 @@ never evaluated---it is ignored. Thus, in the example below,
171@end example 172@end example
172@end defspec 173@end defspec
173 174
175@defspec when condition then-forms@dots{}
176This is a variant of @code{if} where there are no @var{else-forms},
177and possibly several @var{then-forms}. In particular,
178
179@example
180(when @var{condition} @var{a} @var{b} @var{c})
181@end example
182
183@noindent
184is entirely equivalent to
185
186@example
187(if @var{condition} (progn @var{a} @var{b} @var{c}) nil)
188@end example
189@end defspec
190
191@defspec unless condition forms@dots{}
192This is a variant of @code{if} where there is no @var{then-form}:
193
194@example
195(unless @var{condition} @var{a} @var{b} @var{c})
196@end example
197
198@noindent
199is entirely equivalent to
200
201@example
202(if @var{condition} nil
203 @var{a} @var{b} @var{c})
204@end example
205@end defspec
206
174@defspec cond clause@dots{} 207@defspec cond clause@dots{}
175@code{cond} chooses among an arbitrary number of alternatives. Each 208@code{cond} chooses among an arbitrary number of alternatives. Each
176@var{clause} in the @code{cond} must be a list. The @sc{car} of this 209@var{clause} in the @code{cond} must be a list. The @sc{car} of this