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

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

Re: Declaring a local dynamic variable?


From: Andreas Röhler
Subject: Re: Declaring a local dynamic variable?
Date: Sat, 21 Sep 2013 15:32:42 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

Am 21.09.2013 13:31, schrieb Barry Margolin:
In article <mailman.2622.1379742443.10748.help-gnu-emacs@gnu.org>,
  Andreas Röhler <andreas.roehler@easy-emacs.de> wrote:

Am 20.09.2013 22:59, schrieb Barry Margolin:
In article <mailman.2578.1379694764.10748.help-gnu-emacs@gnu.org>,
   Andreas Röhler <andreas.roehler@easy-emacs.de> wrote:

Am 20.09.2013 17:10, schrieb Barry Margolin:
In article <mailman.2569.1379688787.10748.help-gnu-emacs@gnu.org>,
    Andreas Röhler <andreas.roehler@easy-emacs.de> wrote:

Am 20.09.2013 14:30, schrieb Stefan Monnier:
If I purposefully use a local dynamic variable as in:

Use (defvar my-counter) at the file's top-level to indicate that this
variable is used in a way that relies on dynamic scoping.

A need to write code just to silence compiler warnings?
Emacs could do better.

Other than "code", what would you suggest?

In the precise case: just drop that warning.

In a wider sense, IMO a modular approach is better.
Restrict compiler warnings to obvious errors, don't mix style questions in.

This isn't a style warning. Often the reason is mistyping a local
variable name.

(let ((foobar ...))
     ...
     (blah fobar)
     ...)


This is another case. IIUC there was nothing wrong with the OP's example.

But how is the compiler supposed to know the difference?

A code-checker might look up, if a variable is defined.
If our eyes may notice the difference, why a checker should not?

 Either it
always warns, and generate false positives when you compile the user of
a variable before loading the defvar, or never warns and there are false
negatives when the user makes a typo.

In this case, false positives are the better option, since you can
easily silence them by adding a defvar. If the warning were removed,
there's no way to get the warning when you actually do make a typo.


Unfortunatly it's not the only occassion. Compiler message is cluttered with 
false positives that way.




reply via email to

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