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 12:07:43 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Jan 08, 2021 at 09:28:58AM +0100, Emanuel Berg via Users list for the 
GNU Emacs text editor wrote:

[...]

> Question 2: Why is this problem so difficult to solve at its
> source? What's with these functions that enables them to
> cloak, if you will, so the byte compiler cannot se what the
> human eye can see instantly, looking at the same material?

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 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.

Fixing that would take

 (a) special-casing dotimes somehow. For maintaniability
    reasons probably out of the question
 (b) making the macro expander for dotimes smarter, to
    skip introducing the let-binding. I'm not good enough
    at macrology to even fathom what that means. Possibly
    we end up with a macro three times as complex for very
    little gain
 (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).

Makes more sense now?

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

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