Warn on unused imports?

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Mon Oct 1 18:36:49 UTC 2018


On 09/25/2018 09:13 PM, Jonathan M Davis wrote:
> IMHO, the only time that anything along the lines of a warning
> makes sense is when the programmer is proactively running a tool to
> specifically ask to be informed of a potential type of problem where they
> will then go look at each of them individually and decide whether what the
> tool is telling them is valid or not - at which point, some of what the tool
> says will be followed, and some if it will be ignored.

Yes, that's exactly what warnings are for. If people need to treat them 
differently than that (ex: C++), that's a failing of the language.

 > If it is, then inevitably
 > what happens is that either all of the warnings get "fixed" (at
 > which point, they might as well have all been errors),

They only "might as well have all been errors" if the programmer always 
fixes them all before running any of his intermediary builds. It's one 
matter if it's right before a release or often a VCS commit, but plenty 
of very helpful messages can become a major pain while *developing* an 
individual commit.

 > or they all get
 > ignored, meaning that you get a huge wall of them, and
 > they're completely useless.

I'd probably have a tendency to fall into one of those two traps too if 
I were using C++. Outside of C++, I'm not in either of those categories. 
So, so much for that false dichotomy being "inevitable".

> As such, I really have nothing good to say about having any kind of
> warnings being built into the compiler.

Whether or not they're built into the compiler is completely orthogonal 
to the acceptable use-case you described above.

> As I understand it, on the whole,
> Walter agrees with me and that he only added them in to dmd, because he was
> essentially bullied into it,

And I'm very glad he was, because many of those warnings have saved my 
ass on more than one occasion, but would've been completely non-existent 
it if were completely up to Walter.

Plus, other warnings (like deprecations, for example) which have proven 
extremely helpful would have been a major problem had they been outright 
errors.

And realistically, I, and likely most of us, frequently wouldn't have 
bothered if they had been in a separate a tool, certainly not before 
every commit. (Right, as if most C programmers actually *use* lint 
regularly?) It's the same "built-in unittests and docs" effect.


More information about the Digitalmars-d mailing list