aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2024-10-23 09:07:06 +0800
committerSean Whitton2024-10-23 09:08:27 +0800
commit09e05f7ee4de89f5f1dd95aa9498feccfa9a78d6 (patch)
tree6069cdf7181a3ec82e01286f63299f7ece5f81f2
parentb7a375f5c49ac86399b9af7a6a74720ed294abd7 (diff)
downloademacs-09e05f7ee4de89f5f1dd95aa9498feccfa9a78d6.tar.gz
emacs-09e05f7ee4de89f5f1dd95aa9498feccfa9a78d6.zip
Document and-let* vs. when-let* usage convention
* lisp/subr.el (and-let*): Document and/and-let* vs. when/when-let* usage convention (some discussion in bug#73853). (when-let*): Add cross-reference to and-let*.
-rw-r--r--lisp/subr.el12
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 28ba30f584e..d1b2a1efe6e 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2640,14 +2640,22 @@ This is like `if-let' but doesn't handle a VARLIST of the form
2640(defmacro when-let* (varlist &rest body) 2640(defmacro when-let* (varlist &rest body)
2641 "Bind variables according to VARLIST and conditionally evaluate BODY. 2641 "Bind variables according to VARLIST and conditionally evaluate BODY.
2642This is like `when-let' but doesn't handle a VARLIST of the form 2642This is like `when-let' but doesn't handle a VARLIST of the form
2643\(SYMBOL SOMETHING) specially." 2643\(SYMBOL SOMETHING) specially.
2644
2645See also `and-let*'."
2644 (declare (indent 1) (debug if-let*)) 2646 (declare (indent 1) (debug if-let*))
2645 (list 'if-let* varlist (macroexp-progn body))) 2647 (list 'if-let* varlist (macroexp-progn body)))
2646 2648
2647(defmacro and-let* (varlist &rest body) 2649(defmacro and-let* (varlist &rest body)
2648 "Bind variables according to VARLIST and conditionally evaluate BODY. 2650 "Bind variables according to VARLIST and conditionally evaluate BODY.
2649Like `when-let*', except if BODY is empty and all the bindings 2651Like `when-let*', except if BODY is empty and all the bindings
2650are non-nil, then the result is the value of the last binding." 2652are non-nil, then the result is the value of the last binding.
2653
2654Some Lisp programmers follow the convention that `and' and `and-let*'
2655are for forms evaluated for return value, and `when' and `when-let*' are
2656for forms evaluated for side-effect with returned values ignored."
2657 ;; Document this convention here because it partially explains why we
2658 ;; have both `when-let*' and `and-let*'.
2651 (declare (indent 1) (debug if-let*)) 2659 (declare (indent 1) (debug if-let*))
2652 (let (res) 2660 (let (res)
2653 (if varlist 2661 (if varlist