Wish: Variable Not Used Warning

Nick Sabalausky a at a.a
Tue Jul 8 02:34:35 PDT 2008


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:g4v646$c2j$1 at digitalmars.com...
> Robert Fraser wrote:
>> Walter Bright wrote:
>>> Robert Fraser wrote:
>>>> The compiler already has full semantic knowledge of the code, and at 
>>>> least some of the warnings seem like "low-hanging fruit" so why not 
>>>> make the compiler act as a "mini-lint"?
>>>
>>> Generally for the reasons already mentioned.
>>>
>>> Warnings are properly in the scope of static analysis tools, which have 
>>> a different purpose than a compiler.
>>
>> A compiler is not a documentation generator or a header generator, yet 
>> DMD does both (with some switches). Why not the same with lint-like 
>> functionality?
>
> Because what constitutes a proper warning is a very subjective issue, 
> there is plenty of room for different ideas.

Ok, so the different warnings should be able to be turned on and off. If you 
don't agree with a particular type of warning then you turn it off. That's 
the nice thing about warnings as opposed to errors: they're optionally 
letting you know about certain conditions that you might want to be aware 
of, and they do it without changing, redefining, or otherwise affecting the 
language itself.

> If it was in the compiler, it would inhibit development of static analysis 
> tools,

Can you elaborate on how this would happen?

> and would confuse the issue of what was correct D code.

Anything that generates a warning instead of an error is by definition valid 
code. If it wasn't valid it would generate an error instead of a warning.

Although, if by "correct" you're referring to style guidelines instead of 
syntactic and semantic validity, then I still disagree that it's an issue. 
For instance, I don't think many people would be opposed to having an 
optional switch that checked for consistent indentation style (I'm not 
actually requesting this though). People have different indentation style 
preferences, so the type of indentation could be configued, but perhaps have 
some sort of default. I can't imagine that confusing people as to what 
correct style was. Anyone who isn't an absolute novice is well aware of what 
does and doesn't constitute an issue of style (If it doesn't cause 
compile-time/runtime errors, then it's a matter of style). 





More information about the Digitalmars-d mailing list