Wish: Variable Not Used Warning
Markus Koskimies
markus at reaaliaika.net
Wed Jul 9 23:45:42 PDT 2008
On Wed, 09 Jul 2008 17:53:52 -0400, Nick Sabalausky wrote:
> In a "properly defined language", how would you solve the problem of
> unintentionally-unused variables?
My suggestion: just give error. No need for "unused" keyword, just
comment out code that has no effects.
For function arguments, if they are unused but mandatory because of
keeping interface, leave it without name if it is not used.
Furthermore, give also errors unused private/static things. If they are
not used, why are they in the code? Just comment them out.
In similar manner, warn about conditional expressions that have constant
value (like "uint a; if(a > 0) { ... }"), code that has no effect and all
those things :)
And yes, warnings could be considered as "optional errors" for us who
think that it's best to tackle all sorts of quirks & potential bugs at
compile time and not trying to find them with runtime debugging. As long
as the warning makes some sense and can be circumvented in some
reasonable way, just throw it to my screen :)
More information about the Digitalmars-d
mailing list