Wish: Variable Not Used Warning

Walter Bright newshound1 at digitalmars.com
Tue Jul 8 23:02:10 PDT 2008


Nick Sabalausky wrote:
>> The problem with warnings is that if there are n warnings, there are 
>> essentially n factorial different versions of the language.
> I really don't see how this is, unless every compiler always has "treat 
> warnings as errors" permanently enabled with no way to disable. That's like 
> saying that using different lint tools, or different settings within a the 
> same lint tool constitutes different versions of the same language, and then 
> claiming that means we shouldn't use lint tools.

If you have 10 warnings, each independently toggled on or off, then you 
have 10 factorial different languages. The difference between lint and a 
compiler is people know lint is not a compiler and do not worry about 
lint's complaints. Warnings in the compiler are treated, in reality, 
like programming errors.

>>  If you're faced with compiling someone else's code (like you downloaded 
>> it off the internet and have to compile it because it only is distributed 
>> as source) and warnings go off, is that a bug in the code or not? What do 
>> you do?
> By definition, that's not an error.

I know, but that is NOT how they are perceived. People wonder if they 
downloaded it right, or if they downloaded the right version, they 
wonder if they should complain about it, they wonder if the program will 
work properly if compiled. It sucks.

>> Some shops have a "thou shall compile with warnings enabled, and there 
>> shall be no warning messages."
> That's a management problem, not a compiler design problem.

Management of programming teams is an important issue. There are a 
number of characteristics in D that try to make it easier for managers 
to manage the programmers. These are based on my conversations with many 
managers about the kinds of problems they face. I don't agree that these 
issues should be ignored and dismissed as just a management problem.

>> Those kind of things tend to interfere with the beauty of the code, and 
>> since they are not necessary to the program's logic, they tend to confuse 
>> and misdirect the maintenance programmer (why is this variable pointlessly 
>> referenced here? Why is this unreachable return statement here? Is this a 
>> bug?)
> Thus comments.

I don't agree with relying on comments to make up for a language design 
that encourages confusing and misleading code to be written.


> Like I've said, compiler warnings are essentialy a built-in lint tool. I see 
> no reason to think of them any other way. 

I think you and I have had very different experiences with warnings!



More information about the Digitalmars-d mailing list