Wish: Variable Not Used Warning

Manfred_Nowak svv1999 at hotmail.com
Wed Jul 9 06:43:54 PDT 2008


Koroskin Denis wrote:

> You asked an example, I provided one. There is another one:
[...]

Bearophile asked for a _practical_ example. But your example seems to 
illustrate consequences rooted in a coding style and not rooted in the 
absence of an `unused' keyword and its semantics.


> I was going to modify local variable, but not a member. 

This is a well known phenomenon. But again no need for an `unused' 
keyword shows up. To the contrary: within the function you want to use 
both variables, although one of them only for reading.

Pollution of the namspace within the function causes the problem. But 
would you really want to write import statements for variables from 
surrounding scopes?

> Compiler could warn me that I don't use it

This claim comes up once in a while, but seems to be unprovable in 
general. It might be provable in your special case though. But without 
the general proof one may have both:
- many false warnings 
- many true bugs without warnings

Do you have a proof for the general case?

-manfred

-- 
Maybe some knowledge of some types of disagreeing and their relation 
can turn out to be useful:
http://blog.createdebate.com/2008/04/07/writing-strong-arguments/



More information about the Digitalmars-d mailing list