help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to avoid compiler warning `unused lexical variable' for `dolist'


From: tomas
Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Fri, 8 Jan 2021 15:03:22 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Jan 08, 2021 at 02:31:11PM +0100, Emanuel Berg via Users list for the 
GNU Emacs text editor wrote:
> Philipp Stephani wrote:
> 
> >> No! Again, this is a problem with the byte compiler.
> >
> > Not really. The byte compiler can only compile what's
> > macro-expanded
> 
> If the byte compiler because of its nature is incapable of
> doing something, it shouldn't attempt or say anything...

No. The byte compiler is doing exactly what it's been
designed to: dependency analysis. And it making that
"knowledge" it needs anyway available to the programmer
via a warning. That is a Good Thing. And it is even
right in its analysis: there /is/ an let-declared variable
there which is unused.

The macro expander put it there. I think Philipp and me
managed to convince you of that?

[...]

> >   (let ((i counter))
> >     t))
> >
> > As you can see, `i' is definitely unused in the second `let'
> > form - the byte compiler is right.
> 
> Hm... what is the definition of being used in terms of
> a variable? read/write?

I think it's just access (i.e. read). But you could try for yourself
(just cook up a RETURN expression where the count variable is
set and compile that code. Perhaps better don't run it :)

> Also, that is a stub, I don't remember what the OP did but he
> did use it

You mean he used the count variable? In the context of the
RETURN expression? And then (s)he gets the warning? I'd be
surprised. We'd be digging in the wrong place, then.

>            and I think this is what one thinks the byte
> compiler is referring to with its warning rather than certain
> parts of what is macro-expanded...

Hm. Could you provide the original code snippet?

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]