Unused variables, better as error or warning?

KennyTM~ kennytm at gmail.com
Fri Aug 20 13:30:03 PDT 2010

On Aug 21, 10 03:35, Walter Bright wrote:
> Jonathan M Davis wrote:
>> I'm sure that there are cases where it would be nice for the compiler
>> to point out that you're uselessly assigning to a variable (especially
>> if you're making a useless function call too), but it would cost the
>> compiler too much in complexity and cost the programmer in many other
>> cases by forcing them to either ignore warnings (which they should
>> pretty much never do) or throw in pointless explicit initializations
>> rather than letting the defaults do their job.
> Having such be errors (or warnings) makes for a very annoying
> experience. For example, when you're commenting out code trying to find
> a problem, or when you're generating D source code from some DSL, etc.,
> having unused variables or assignments happen often.

That's why other compilers support fine-grained warning control! :)

More information about the Digitalmars-d mailing list