1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-26 10:49:33 +00:00

De-obsolete if-let' and when-let'

For the following release it is planned to make `if-let*' and
`when-let*' aliases for `if-let' and `when-let'.  For now we revert
declaring `if-let' and `when-let' obsolete and tweak the docstrings.

* lisp/emacs-lisp/subr-x.el (if-let*, when-let*): Make docstrings
refer to those of `if-let' and `when-let'.
(if-let, when-let): De-obsolete.  Rewrite documentation.
This commit is contained in:
Michael Heerdegen 2018-03-10 16:39:41 +01:00
parent 86960383cf
commit 441fe201ea
2 changed files with 28 additions and 26 deletions

View File

@ -1305,12 +1305,8 @@ current buffer or the self-insertion takes place within a comment.
** The alist 'ucs-names' is now a hash table.
---
** 'if-let' and 'when-let' are subsumed by 'if-let*' and 'when-let*'.
The incumbent 'if-let' and 'when-let' are now marked obsolete.
'if-let*' and 'when-let*' do not accept the single tuple special case.
New macro 'and-let*' is an implementation of the Scheme SRFI-2 syntax
of the same name. 'if-let*' and 'when-let*' now accept the same
binding syntax as 'and-let*'.
** 'if-let' and 'when-let' now support binding lists as defined by the
SRFI-2 (Scheme Request for Implementation 2).
---
** 'C-up', 'C-down', 'C-left' and 'C-right' are now defined in term

View File

@ -123,15 +123,8 @@ If ELT is of the form ((EXPR)), listify (EXPR) with a dummy symbol."
(defmacro if-let* (varlist then &rest else)
"Bind variables according to VARLIST and eval THEN or ELSE.
Each binding is evaluated in turn, and evaluation stops if a
binding value is nil. If all are non-nil, the value of THEN is
returned, or the last form in ELSE is returned.
Each element of VARLIST is a list (SYMBOL VALUEFORM) which binds
SYMBOL to the value of VALUEFORM. An element can additionally
be of the form (VALUEFORM), which is evaluated and checked for
nil; i.e. SYMBOL can be omitted if only the test result is of
interest."
This is like `if-let' but doesn't handle a VARLIST of the form
\(SYMBOL SOMETHING) specially."
(declare (indent 2)
(debug ((&rest [&or symbolp (symbolp form) (form)])
form body)))
@ -144,11 +137,8 @@ interest."
(defmacro when-let* (varlist &rest body)
"Bind variables according to VARLIST and conditionally eval BODY.
Each binding is evaluated in turn, and evaluation stops if a
binding value is nil. If all are non-nil, the value of the last
form in BODY is returned.
VARLIST is the same as in `if-let*'."
This is like `when-let' but doesn't handle a VARLIST of the form
\(SYMBOL SOMETHING) specially."
(declare (indent 1) (debug if-let*))
(list 'if-let* varlist (macroexp-progn body)))
@ -168,12 +158,25 @@ are non-nil, then the result is non-nil."
(defmacro if-let (spec then &rest else)
"Bind variables according to SPEC and eval THEN or ELSE.
Like `if-let*' except SPEC can have the form (SYMBOL VALUEFORM)."
Each binding is evaluated in turn, and evaluation stops if a
binding value is nil. If all are non-nil, the value of THEN is
returned, or the last form in ELSE is returned.
Each element of SPEC is a list (SYMBOL VALUEFORM) which binds
SYMBOL to the value of VALUEFORM. An element can additionally be
of the form (VALUEFORM), which is evaluated and checked for nil;
i.e. SYMBOL can be omitted if only the test result is of
interest. It can also be of the form SYMBOL, then the binding of
SYMBOL is checked for nil.
As a special case, a SPEC of the form \(SYMBOL SOMETHING) is
interpreted like \((SYMBOL SOMETHING)). This exists for backward
compatibility with the old syntax that accepted only one
binding."
(declare (indent 2)
(debug ([&or (&rest [&or symbolp (symbolp form) (form)])
(symbolp form)]
form body))
(obsolete "use `if-let*' instead." "26.1"))
form body)))
(when (and (<= (length spec) 2)
(not (listp (car spec))))
;; Adjust the single binding case
@ -182,9 +185,12 @@ Like `if-let*' except SPEC can have the form (SYMBOL VALUEFORM)."
(defmacro when-let (spec &rest body)
"Bind variables according to SPEC and conditionally eval BODY.
Like `when-let*' except SPEC can have the form (SYMBOL VALUEFORM)."
(declare (indent 1) (debug if-let)
(obsolete "use `when-let*' instead." "26.1"))
Each binding is evaluated in turn, and evaluation stops if a
binding value is nil. If all are non-nil, the value of the last
form in BODY is returned.
The variable list SPEC is the same as in `if-let'."
(declare (indent 1) (debug if-let))
(list 'if-let spec (macroexp-progn body)))
(defsubst hash-table-empty-p (hash-table)