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: Emanuel Berg
Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?
Date: Fri, 08 Jan 2021 13:38:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

tomas wrote:

> I think Stefan explained that pretty well in this thread:
> dotimes is implemented as a macro (the alternative would be
> to special-case it) which introduces a let-binding

But surely this happens elsewhere as well?

> to the counting index... which is used in the result part,
> unless it's not used, which then causes the byte compiler to
> issue the warning.

But the warning isn't specifically introduced for this
situation, is it? Because then it could just say that, instead
of the confusing wasn't used thing.

But if it isn't, then why is it triggered by this at all and
how can it be so specific to even act upon a certain part of
the construct?

> Fixing that would take
>
>  (a) special-casing dotimes somehow. For maintaniability
>      reasons probably out of the question

No.

>  (b) making the macro expander for dotimes smarter, to
>     skip introducing the let-binding.

No.

>  (c) (that seems Stefan's favourite, and I tend to trust him
>      blindly in those things) discourage the three argument
>      use of dotimes, since it's not that idiomatic in Elisp
>      anyway (those idioms are more Common Lisp-y).

Ha :) Well, whatever.

> Makes more sense now?

No! Again, this is a problem with the byte compiler.
So rather, fixing it would take

   (d) fixing the byte compiler

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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