summaryrefslogtreecommitdiff
path: root/lispref
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-01-09 07:58:14 +0000
committerRichard M. Stallman <rms@gnu.org>1997-01-09 07:58:14 +0000
commit220355856bebcb669bb6892d0e5caccd05676c57 (patch)
tree8d6b6018062ee75cff3a14b2f2ddfea2f5ddfc44 /lispref
parent15d3cfb116d69b447c6da7fb8c6b0e028e60b197 (diff)
downloademacs-220355856bebcb669bb6892d0e5caccd05676c57.tar.gz
Add when and unless.
Diffstat (limited to 'lispref')
-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
@cindex conditional evaluation
Conditional control structures choose among alternatives. Emacs Lisp
-has two conditional forms: @code{if}, which is much the same as in other
-languages, and @code{cond}, which is a generalized case statement.
+has four conditional forms: @code{if}, which is much the same as in
+other languages; @code{when} and @code{unless}, which are variants of
+@code{if}; and @code{cond}, which is a generalized case statement.
@defspec if condition then-form else-forms@dots{}
@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,
@end example
@end defspec
+@defspec when condition then-forms@dots{}
+This is a variant of @code{if} where there are no @var{else-forms},
+and possibly several @var{then-forms}. In particular,
+
+@example
+(when @var{condition} @var{a} @var{b} @var{c})
+@end example
+
+@noindent
+is entirely equivalent to
+
+@example
+(if @var{condition} (progn @var{a} @var{b} @var{c}) nil)
+@end example
+@end defspec
+
+@defspec unless condition forms@dots{}
+This is a variant of @code{if} where there is no @var{then-form}:
+
+@example
+(unless @var{condition} @var{a} @var{b} @var{c})
+@end example
+
+@noindent
+is entirely equivalent to
+
+@example
+(if @var{condition} nil
+ @var{a} @var{b} @var{c})
+@end example
+@end defspec
+
@defspec cond clause@dots{}
@code{cond} chooses among an arbitrary number of alternatives. Each
@var{clause} in the @code{cond} must be a list. The @sc{car} of this