mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Update special conditionals documentation
* doc/lispref/control.texi (Conditionals): Document if-let* and when-let*, not if-let and when-let. Document and-let*.
This commit is contained in:
parent
75584a3a96
commit
eae798486a
1 changed files with 18 additions and 7 deletions
|
|
@ -313,7 +313,7 @@ to make this easier and more readable. The above can be written the
|
||||||
following way instead:
|
following way instead:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
(when-let ((result1 (do-computation))
|
(when-let* ((result1 (do-computation))
|
||||||
(result2 (do-more result1)))
|
(result2 (do-more result1)))
|
||||||
(do-something result2))
|
(do-something result2))
|
||||||
@end example
|
@end example
|
||||||
|
|
@ -321,22 +321,33 @@ following way instead:
|
||||||
There's a number of variations on this theme, and they're briefly
|
There's a number of variations on this theme, and they're briefly
|
||||||
described below.
|
described below.
|
||||||
|
|
||||||
@defmac if-let spec then-form else-forms...
|
@defmac if-let* varlist then-form else-forms...
|
||||||
Evaluate each binding in @var{spec} in turn, like in @code{let*}
|
Evaluate each binding in @var{varlist} in turn, like in @code{let*}
|
||||||
(@pxref{Local Variables}), stopping if a binding value is @code{nil}.
|
(@pxref{Local Variables}), stopping if a binding value is @code{nil}.
|
||||||
If all are non-@code{nil}, return the value of @var{then-form},
|
If all are non-@code{nil}, return the value of @var{then-form},
|
||||||
otherwise the last form in @var{else-forms}.
|
otherwise the last form in @var{else-forms}.
|
||||||
@end defmac
|
@end defmac
|
||||||
|
|
||||||
@defmac when-let spec then-forms...
|
@defmac when-let* varlist then-forms...
|
||||||
Like @code{if-let}, but without @var{else-forms}.
|
Like @code{if-let*}, but without @var{else-forms}.
|
||||||
|
@end defmac
|
||||||
|
|
||||||
|
@defmac and-let* varlist then-forms...
|
||||||
|
Like @code{when-let*}, but in addition, if there are no
|
||||||
|
@var{then-forms} and all the bindings evaluate to non-nil, return the
|
||||||
|
value of the last binding.
|
||||||
@end defmac
|
@end defmac
|
||||||
|
|
||||||
@defmac while-let spec then-forms...
|
@defmac while-let spec then-forms...
|
||||||
Like @code{when-let}, but repeat until a binding in @var{spec} is
|
Like @code{when-let*}, but repeat until a binding in @var{spec} is
|
||||||
@code{nil}. The return value is always @code{nil}.
|
@code{nil}. The return value is always @code{nil}.
|
||||||
@end defmac
|
@end defmac
|
||||||
|
|
||||||
|
Some Lisp programmers follow the convention that @code{and} and
|
||||||
|
@code{and-let*} are for forms evaluated for return value, and
|
||||||
|
@code{when} and @code{when-let*} are for forms evaluated for side-effect
|
||||||
|
with returned values ignored.
|
||||||
|
|
||||||
@node Combining Conditions
|
@node Combining Conditions
|
||||||
@section Constructs for Combining Conditions
|
@section Constructs for Combining Conditions
|
||||||
@cindex combining conditions
|
@cindex combining conditions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue