Unused variables, better as error or warning?

Walter Bright newshound2 at digitalmars.com
Fri Aug 20 16:27:11 PDT 2010

bearophile wrote:
> If
> your language (C, D, etc) allows you to not use a variable the last time you
> have initialized it, and then you want to add a warning that finds such
> situations, you don't need the compiler to be 100% accurate, even if some of
> such situations are not detected then it's perfectly OK.

Then you're faced with one of two unpleasant consequences:

1. You have to build the logic of what cases you detect into the specification. 
This leads to user confusion about the why's of this and gives a bad impression 
about the arbitrary nature of it.

2. You are faced with errors building with one compiler and no errors on 
another. I.e. your code loses portability.

More information about the Digitalmars-d mailing list