Wish: Variable Not Used Warning

Nick Sabalausky a at a.a
Thu Jul 10 11:55:49 PDT 2008


"Markus Koskimies" <markus at reaaliaika.net> wrote in message 
news:g549hh$1h9i$2 at digitalmars.com...
> On Wed, 09 Jul 2008 15:13:15 -0700, Davidson Corry wrote:
>
>> I *also* want a tool (or sheaf of tools, smart editor, etc.) that will
>> do lint-like static analysis and style vetting to warn me that, yes,
>> this is legal D but you're using it in an obscure or unmaintainable or
>> not easily extensible or not easily understood manner.
>> _But_I_don't_want_that_tool_to_be_the_compiler_!
>
> Oh, I would like to see that as a part of a compiler. In fact, the more
> the compiler generates warnings, the more I like it.

Right. See, even if you don't want that tool to be your compiler...you don't 
have to turn that feature on. If I want to use a TV remote, I can do so 
without dealing with the buttons that are built into the TV.

>> Walter is right that you end up with effectively 2**n different
>> languages depending, not only on which warnings you enable|disable, but
>> also on whether the shop you work for demands that you compile at /W1 or
>> /W3 or /W4 and does or doesn't treat warnings as errors.
>
> Ah, there needs only be one warning level - enable all, and regard
> warnings as errors. Who wants to disable warnings? Who want only see part
> of warnings? Just no use, IMO it's just OK to put all of them to screen
> and not to compile until the programmer has corrected those :)
>

I'm not sure I see the need for as many as four warning levels (though I 
suppose I could be convinced given an appropriate argument), but something 
like this sounds ideal to me:

- enable typically-useful warnings
- enable anally-retentive, only sometimes-helpful, warnings

- treat typically-useful warnings as errors
- treat all warnings as errors

>> I applaud Walter for not making that error. And I want him focused on
>> writing a knife-clean compiler that stabs illegal code in the heart, and
>> trusts the programmer to have meant what he said when the code is legal,
>> even if it's "excessively clever".
>
> Heh, I like compilers that does not over-estimate the cleverness of the
> developer, but instead think that they (compilers) are the smarter
> part ;) Although being well known with syntax and best practices of a
> language, many times I write something else than I thought that I wrote.
> For catching these kind of spurious "miswritings", there are "syntactic
> salt" in many languages, including D. But at some point I think that it's
> no use to add more this salt, but instead do static checks to make the
> language better.
>

At the risk of a "me too" post...Me too ;)





More information about the Digitalmars-d mailing list