aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-10-07 17:31:34 +0100
committerSean Whitton2025-10-07 17:35:06 +0100
commitda47fa2f23bde6cc96f90f56ccf383128affb748 (patch)
treea93364fe60ebd2bae74ead9f0a6aab0ef77b23ce
parentdb7fd704deee3cbb7d7af72126c992cbc55383f9 (diff)
downloademacs-da47fa2f23bde6cc96f90f56ccf383128affb748.tar.gz
emacs-da47fa2f23bde6cc96f90f56ccf383128affb748.zip
if-let*/when-let*/and-let*: Don't recommend (VALUEFORM) form
* doc/lispref/control.texi (Conditionals): * lisp/subr.el (if-let*): Document '(_ VALUEFORM)' instead of '(VALUEFORM)'.
-rw-r--r--doc/lispref/control.texi21
-rw-r--r--lisp/subr.el21
2 files changed, 25 insertions, 17 deletions
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 689e7324d43..8f1f144e765 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -317,7 +317,7 @@ following way instead:
317 (do-something result2)) 317 (do-something result2))
318@end example 318@end example
319 319
320There's a number of variations on this theme, and they're briefly 320There are a number of variations on this theme, and they're briefly
321described below. 321described below.
322 322
323@defmac if-let* varlist then-form else-forms... 323@defmac if-let* varlist then-form else-forms...
@@ -328,10 +328,9 @@ Evaluate each binding in @var{varlist}, stopping if a binding value is
328Each element of @code{varlist} has the form @w{@code{(@var{symbol} 328Each element of @code{varlist} has the form @w{@code{(@var{symbol}
329@var{value-form})}}: @var{value-form} is evaluated and @var{symbol} is 329@var{value-form})}}: @var{value-form} is evaluated and @var{symbol} is
330locally bound to the result. Bindings are sequential, as in @code{let*} 330locally bound to the result. Bindings are sequential, as in @code{let*}
331(@pxref{Local Variables}). As a special case, @var{symbol} can be 331(@pxref{Local Variables}). If only the test result of @var{value-form}
332omitted if only the test result of @var{value-form} is of interest: 332is of interest, use @code{_} for @var{symbol}. Then @var{value-form} is
333@var{value-form} is evaluated and checked for @code{nil}, but its value 333evaluated and checked for @code{nil}, but its value is not bound.
334is not bound.
335@end defmac 334@end defmac
336 335
337@defmac when-let* varlist then-forms... 336@defmac when-let* varlist then-forms...
@@ -343,8 +342,8 @@ form in @var{then-forms}.
343@code{varlist} has the form @w{@code{(@var{symbol} @var{value-form})}}, 342@code{varlist} has the form @w{@code{(@var{symbol} @var{value-form})}},
344in which @var{value-form} is evaluated and @var{symbol} is locally bound 343in which @var{value-form} is evaluated and @var{symbol} is locally bound
345to the result. Bindings are sequential, as in @code{let*} (@pxref{Local 344to the result. Bindings are sequential, as in @code{let*} (@pxref{Local
346Variables}). As a special case, @var{symbol} can be omitted if only the 345Variables}). If only the test result of @var{value-form}
347test result of @var{value-form} is of interest: @var{value-form} is 346is of interest, use @code{_} for @var{symbol}. Then @var{value-form} is
348evaluated and checked for @code{nil}, but its value is not bound. 347evaluated and checked for @code{nil}, but its value is not bound.
349@end defmac 348@end defmac
350 349
@@ -358,8 +357,8 @@ the value of the last binding.
358@code{varlist} has the form @w{@code{(@var{symbol} @var{value-form})}}, 357@code{varlist} has the form @w{@code{(@var{symbol} @var{value-form})}},
359in which @var{value-form} is evaluated and @var{symbol} is locally bound 358in which @var{value-form} is evaluated and @var{symbol} is locally bound
360to the result. Bindings are sequential, as in @code{let*} (@pxref{Local 359to the result. Bindings are sequential, as in @code{let*} (@pxref{Local
361Variables}). As a special case, @var{symbol} can be omitted if only the 360Variables}). If only the test result of @var{value-form} is of
362test result of @var{value-form} is of interest: @var{value-form} is 361interest, use @code{_} for @var{symbol}. Then @var{value-form} is
363evaluated and checked for @code{nil}, but its value is not bound. 362evaluated and checked for @code{nil}, but its value is not bound.
364@end defmac 363@end defmac
365 364
@@ -382,8 +381,8 @@ established anew.
382@code{varlist} has the form @w{@code{(@var{symbol} @var{value-form})}}, 381@code{varlist} has the form @w{@code{(@var{symbol} @var{value-form})}},
383in which @var{value-form} is evaluated and @var{symbol} is locally bound 382in which @var{value-form} is evaluated and @var{symbol} is locally bound
384to the result. Bindings are sequential, as in @code{let*} (@pxref{Local 383to the result. Bindings are sequential, as in @code{let*} (@pxref{Local
385Variables}). As a special case, @var{symbol} can be omitted if only the 384Variables}). If only the test result of @var{value-form} is of
386test result of @var{value-form} is of interest: @var{value-form} is 385interest, use @code{_} for @var{symbol}. Then @var{value-form} is
387evaluated and checked for @code{nil}, but its value is not bound. 386evaluated and checked for @code{nil}, but its value is not bound.
388 387
389The return value of @code{while-let} is always @code{nil}. 388The return value of @code{while-let} is always @code{nil}.
diff --git a/lisp/subr.el b/lisp/subr.el
index 50ebc598e80..7bd436d898a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2632,6 +2632,9 @@ Affects only hooks run in the current buffer."
2632 binding)) 2632 binding))
2633 bindings))) 2633 bindings)))
2634 2634
2635;; FIXME: Once Emacs 29 is ancient history we can consider a
2636;; byte-compiler warning. This is because Emacs 29 and older will warn
2637;; about unused variables with (_ VALUEFORM).
2635(defmacro if-let* (varlist then &rest else) 2638(defmacro if-let* (varlist then &rest else)
2636 "Bind variables according to VARLIST and evaluate THEN or ELSE. 2639 "Bind variables according to VARLIST and evaluate THEN or ELSE.
2637Evaluate each binding in turn, as in `let*', stopping if a 2640Evaluate each binding in turn, as in `let*', stopping if a
@@ -2639,12 +2642,18 @@ binding value is nil. If all are non-nil return the value of
2639THEN, otherwise the value of the last form in ELSE, or nil if 2642THEN, otherwise the value of the last form in ELSE, or nil if
2640there are none. 2643there are none.
2641 2644
2642Each element of VARLIST is a list (SYMBOL VALUEFORM) that binds 2645Each element of VARLIST is a list (SYMBOL VALUEFORM) that binds SYMBOL
2643SYMBOL to the value of VALUEFORM. An element can additionally be 2646to the value of VALUEFORM. If only the test result is of interest, use
2644of the form (VALUEFORM), which is evaluated and checked for nil; 2647`_' as SYMBOL, i.e. (_ VALUEFORM), in which case VALUEFORM is evaluated
2645i.e. SYMBOL can be omitted if only the test result is of 2648and checked for nil but the result is not bound.
2646interest. It can also be of the form SYMBOL, then the binding of 2649An element of VARLIST can also be of the form SYMBOL, in which case the
2647SYMBOL is checked for nil." 2650binding of SYMBOL is checked for nil, only.
2651
2652An older form for entries of VARLIST is also supported, where SYMBOL is
2653omitted, i.e. (VALUEFORM). This means the same as (_ VALUEFORM).
2654This form is not recommended because many programmers find it
2655significantly less readable. A future release of Emacs may introduce a
2656byte-compiler warning for uses of (VALUEFORM) in VARLIST."
2648 (declare (indent 2) 2657 (declare (indent 2)
2649 (debug ((&rest [&or symbolp (symbolp form) (form)]) 2658 (debug ((&rest [&or symbolp (symbolp form) (form)])
2650 body))) 2659 body)))