Wish: Variable Not Used Warning
Nick Sabalausky
a at a.a
Wed Jul 9 10:23:05 PDT 2008
"Manfred_Nowak" <svv1999 at hotmail.com> wrote in message
news:g52faq$2s3g$1 at digitalmars.com...
> 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?
>
Can you prove that namespace pollution is the root cause of
"unintentially-unused variable" errors in the general case?
>> 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?
>
Do you have a general-case proof that an "unused variable" warning would
cause too many false warnings/etc.? Would the proof still hold with the
proposed "unused" keyword (or some functionaly-equivilent alternative)?
More information about the Digitalmars-d
mailing list