aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2024-10-24 12:10:09 +0800
committerSean Whitton2024-10-24 12:10:09 +0800
commiteae798486a965ec176bef3cc343625c164986c3f (patch)
treefbebb99b28da80f4d9446c8b6a9d0ab0f0fb3001
parent75584a3a9614541478cf05edc6223de8db3d350c (diff)
downloademacs-eae798486a965ec176bef3cc343625c164986c3f.tar.gz
emacs-eae798486a965ec176bef3cc343625c164986c3f.zip
Update special conditionals documentation
* doc/lispref/control.texi (Conditionals): Document if-let* and when-let*, not if-let and when-let. Document and-let*.
-rw-r--r--doc/lispref/control.texi25
1 files changed, 18 insertions, 7 deletions
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 58063ecf8db..5ccc8462c9e 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -313,30 +313,41 @@ to make this easier and more readable. The above can be written the
313following way instead: 313following way instead:
314 314
315@example 315@example
316(when-let ((result1 (do-computation)) 316(when-let* ((result1 (do-computation))
317 (result2 (do-more result1))) 317 (result2 (do-more result1)))
318 (do-something result2)) 318 (do-something result2))
319@end example 319@end example
320 320
321There's a number of variations on this theme, and they're briefly 321There's a number of variations on this theme, and they're briefly
322described below. 322described below.
323 323
324@defmac if-let spec then-form else-forms... 324@defmac if-let* varlist then-form else-forms...
325Evaluate each binding in @var{spec} in turn, like in @code{let*} 325Evaluate each binding in @var{varlist} in turn, like in @code{let*}
326(@pxref{Local Variables}), stopping if a binding value is @code{nil}. 326(@pxref{Local Variables}), stopping if a binding value is @code{nil}.
327If all are non-@code{nil}, return the value of @var{then-form}, 327If all are non-@code{nil}, return the value of @var{then-form},
328otherwise the last form in @var{else-forms}. 328otherwise the last form in @var{else-forms}.
329@end defmac 329@end defmac
330 330
331@defmac when-let spec then-forms... 331@defmac when-let* varlist then-forms...
332Like @code{if-let}, but without @var{else-forms}. 332Like @code{if-let*}, but without @var{else-forms}.
333@end defmac
334
335@defmac and-let* varlist then-forms...
336Like @code{when-let*}, but in addition, if there are no
337@var{then-forms} and all the bindings evaluate to non-nil, return the
338value of the last binding.
333@end defmac 339@end defmac
334 340
335@defmac while-let spec then-forms... 341@defmac while-let spec then-forms...
336Like @code{when-let}, but repeat until a binding in @var{spec} is 342Like @code{when-let*}, but repeat until a binding in @var{spec} is
337@code{nil}. The return value is always @code{nil}. 343@code{nil}. The return value is always @code{nil}.
338@end defmac 344@end defmac
339 345
346Some Lisp programmers follow the convention that @code{and} and
347@code{and-let*} are for forms evaluated for return value, and
348@code{when} and @code{when-let*} are for forms evaluated for side-effect
349with returned values ignored.
350
340@node Combining Conditions 351@node Combining Conditions
341@section Constructs for Combining Conditions 352@section Constructs for Combining Conditions
342@cindex combining conditions 353@cindex combining conditions