all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Hi-Angel@yandex.ru, 69108@debbugs.gnu.org
Subject: bug#69108: false-positive warning "variable ‘_’ not left unused" in if-let* and if-let
Date: Sun, 25 Feb 2024 02:54:04 +0100	[thread overview]
Message-ID: <87a5npux4z.fsf@web.de> (raw)
In-Reply-To: <86o7ces1ou.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 18 Feb 2024 08:53:37 +0200")

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

> > [...] repeating a test.  Is this what you prefer?
>
> Yes, I think so.  And you could perhaps avoid repetition of
> (cdr binding) by saving the result of (null (cdr binding)) in
> a local variable.

I went with a separate `cond' branch added instead, I think this is even
simpler.  Ok?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-warn-about-_-not-left-unused-in-if-let-and-ali.patch --]
[-- Type: text/x-diff, Size: 986 bytes --]

From 83d42089a77bc0fa4745f708ca73b5e7cddd1829 Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Fri, 16 Feb 2024 22:07:18 +0100
Subject: [PATCH 1/2] Don't warn about _ not left unused in if-let and alike

The macro expansions did not leave a variable _ unused; this triggered
an irritating compiler warning (bug#69108).

* lisp/subr.el (internal--build-binding): Handle bindings of the form
(_ EXPR) separately.
---
 lisp/subr.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/subr.el b/lisp/subr.el
index c317d558e24..afbe6845d7a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2580,6 +2580,8 @@ internal--build-binding
           (list binding binding))
          ((null (cdr binding))
           (list (make-symbol "s") (car binding)))
+         ((eq '_ (car binding))
+          (list (make-symbol "s") (cadr binding)))
          (t binding)))
   (when (> (length binding) 2)
     (signal 'error
--
2.39.2


[-- Attachment #3: Type: text/plain, Size: 174 bytes --]



> > {My unsuccessful doc tweaks}
>
> [...] I'd prefer to separate it.

Done.  Feel free to tune it to your likes.  Or send me an "ok", then
I'll just commit this version.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0002-WIP-lisp-subr.el-if-let-and-let-Tweak-doc.patch --]
[-- Type: text/x-diff, Size: 1330 bytes --]

From 117a82505c3fe9ec1148cb2a7b870cb8e2eb2b6d Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
Date: Sun, 18 Feb 2024 02:27:56 +0100
Subject: [PATCH 2/2] WIP: ; * lisp/subr.el (if-let, and-let*): Tweak doc

---
 lisp/subr.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index afbe6845d7a..62600ff49bf 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2622,7 +2622,7 @@ when-let*
 (defmacro and-let* (varlist &rest body)
   "Bind variables according to VARLIST and conditionally evaluate BODY.
 Like `when-let*', except if BODY is empty and all the bindings
-are non-nil, then the result is non-nil."
+are non-nil, then the result is the value of the last binding."
   (declare (indent 1) (debug if-let*))
   (let (res)
     (if varlist
@@ -2635,7 +2635,8 @@ if-let
   "Bind variables according to SPEC and evaluate THEN or ELSE.
 Evaluate each binding in turn, as in `let*', stopping if a
 binding value is nil.  If all are non-nil return the value of
-THEN, otherwise the last form in ELSE.
+THEN, otherwise the value of the last form in ELSE, or nil if
+there are none.

 Each element of SPEC is a list (SYMBOL VALUEFORM) that binds
 SYMBOL to the value of VALUEFORM.  An element can additionally be
--
2.39.2


[-- Attachment #5: Type: text/plain, Size: 146 bytes --]



>   https://en.wikipedia.org/wiki/Construct_state

Thanks.  Did not expect that my change could be interpreted involving
genitive...


Michael.

  reply	other threads:[~2024-02-25  1:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 21:21 bug#69108: false-positive warning "variable ‘_’ not left unused" in if-let* and if-let Konstantin Kharlamov
2024-02-14  1:01 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17  0:28   ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17  8:04     ` Eli Zaretskii
2024-02-17  9:20       ` Konstantin Kharlamov
2024-02-17 11:45         ` Ihor Radchenko
2024-02-17 10:09           ` Konstantin Kharlamov
2024-02-19 12:37             ` Ihor Radchenko
2024-02-19 13:44               ` Konstantin Kharlamov
2024-02-17 21:46         ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17 22:02       ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-18  6:53         ` Eli Zaretskii
2024-02-25  1:54           ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-02-25  7:42             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5npux4z.fsf@web.de \
    --to=bug-gnu-emacs@gnu.org \
    --cc=69108@debbugs.gnu.org \
    --cc=Hi-Angel@yandex.ru \
    --cc=eliz@gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.