unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: unused lexical variable in `cl-loop'
Date: Sat, 01 Oct 2022 00:59:01 +0200	[thread overview]
Message-ID: <87edvscvuy.fsf@dataswamp.org> (raw)
In-Reply-To: 87r0zv3c4w.fsf@sperrhaken.name

Felix Dietrich wrote:

>   (cl-block nil
>     (let*
>         ((i min)
>          (--cl-var-- max)
>          (num nil)
>          (num nil))
>       (while
>           (<= i --cl-var--)
>         (setq num
>               (nconc num
>                      (list i)))
>         (setq i
>               (+ i 1)))
>       num))
>
> The variable ‘num’ is bound twice

That's right, if you bind the same lexical/static variable
more than once you get the "Unused lexical variable" warning
for every occasion and it doesn't matter if it's used or not.

(let ((one 1)  
      (one 1) )
  one)

;; Warning: Unused lexical variable `one'
;; Warning: Unused lexical variable `one'

But if you do this ...

(let ((one 1)
      (one 2) )
  one)

You only get a warning for the first one ...

;; Warning: Unused lexical variable `one'

-- 
underground experts united
https://dataswamp.org/~incal




  reply	other threads:[~2022-09-30 22:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 20:43 unused lexical variable in `cl-loop' Emanuel Berg
2022-09-28 10:58 ` Michael Heerdegen
2022-09-28 12:40 ` Felix Dietrich
2022-09-30 22:59   ` Emanuel Berg [this message]
2022-10-01 15:10     ` Stefan Monnier via Users list for the GNU Emacs text editor

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87edvscvuy.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).