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: Jean Louis
Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Fri, 8 Jan 2021 05:08:26 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Emanuel Berg via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2021-01-08 04:21]:
> Jean Louis wrote:
> 
> >> Same as for any other place where you might declare
> >> a variable that you don't actually use: make sure the var's
> >> name starts with an underscore. This tells the compiler
> >> that you're aware of the fact the var is not used (but
> >> still want this variable there for some reason; e.g.
> >> in dotimes and dolist you don't have the choice not to put
> >> a variable there).
> >> 
> >> Traditionally for `dotimes`, I'd then use `_` as the
> >> variable name unless I really want to give a hint to the
> >> reader about what kind of things I'm counting like (dotimes
> >> (_column-nb ...) ...).
> >
> > That also sounds like workaround around the real problem.
> > In `dotimes' I do use the VAR counted. It is not same as
> > (let ((_ (execute some program without))))
> 
> But is this really a workaround in your case? Because you _do_
> use it!
> 
>   (dolist (_ignored-var '(a b c))
>     (message "%s" _ignored-var) )
> 
>   geh.el:257:1: Warning: variable ‘_ignored-var’ not left unused
> 
> See? Sometimes the byte-compiler gets it right!

Then it is not a real solution as proposed earlier. If used, byte compiler will 
warn. Is it?

I did not test it, it seem like you did.




reply via email to

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