Wish: Variable Not Used Warning

JAnderson ask at me.com
Thu Jul 10 07:27:25 PDT 2008


JAnderson wrote:
> Manfred_Nowak wrote:
>> JAnderson wrote:
>>
>>> The more warnings as errors the better.  If I have to suffer a
>>> little for false positives *shrug*
>>
>> What do you understand by "a little"?
> 
> I don't understand what your asking.  I meant that if I have to fix it 
> because the compiler tells me its an error then so be it.  Its a little 
> pain for a lot of gain.
> 
>>
>> Please look at the example from 
>> http://www.digitalmars.com/webnews/newsgroups.php?
>> art_group=digitalmars.D&article_id=73441
>> Do you recognize how many warnings a lint tool might emit on that code?
>> Would you admit then, that a paranoic lint would be quite useless, 
>> even if it detects that the variable `p' should be accessed?
> 
> I don't understand?  With lint it just gives you hints about what could 
> be wrong.  You pick and choose what to fix.
> 
>> Would you admit, that you yourself are unable to decide whether the 
>> presence of some access statements to `p' should suppress the warning?
> 
> I would prefer this be an error like C#.  In C++ because all my warnings 
> are errors it would be an error too.  If you really want to use an 
> uninitialized variable there should be a work around but it should be 
> harder to do.

Before someone else corrects me.  This is not an error in C# I was 
thinking of "used uninitialized variable" not "variable not used".  I 
And I still prefer errors for these.

> 
>> My understanding of lint tools is, that they incorporate a collection 
>> of programming patterns together with a fuzzy recognition algorithm. 
>> If there are enough hits for a specific pattern, but it is still only 
>> partial implemented, then warnings are generated. Under this the 
>> primary question is: what is so special to the collection of 
>> programming patterns that they can be formalized into a lint tool but 
>> not be used as paradigms in the source language?
> 
> For me, anything that isn't really an error (and I think a lot more of 
> C++ warnings should be errors).  This means the lint effort can be 
> separate.  It means they can continually add and remove checks while the 
> compiler is worked on as a separate effort.  Things like unused 
> variables might be a candidate however being the pedantic coder that I 
> am, I prefer them as errors as well.  I simply don't add an identifier 
> or I semicolon the value when I'm writting stubs.
> 
>>
>> -manfred 



More information about the Digitalmars-d mailing list