Wish: Variable Not Used Warning

Nick Sabalausky a at a.a
Thu Jul 10 12:51:52 PDT 2008


"Nick Sabalausky" <a at a.a> wrote in message 
news:g55ovu$1p0b$1 at digitalmars.com...
> "Markus Koskimies" <markus at reaaliaika.net> wrote in message 
> news:g54tke$1h9i$11 at digitalmars.com...
>> On Thu, 10 Jul 2008 04:16:06 -0700, Era Scarecrow wrote:
>>
>> [...]
>>> //basic declaration to be finished later int isPrime(int number, int[]
>>> primesList) {
>>>     int cnt;
>>>
>>>     return 0; //shut the compiler up for now.
>>> }
>> [...]
>>> //basic declaration to be finished later int isPrime(int number, int[]
>>> primesList) {
>>>     int cnt;
>>>     unusedReferenceToShutUpErrors(cnt);
>>>     unusedReferenceToShutUpErrors(primesList);
>>>
>>>     return 0; //shut the compiler up for now.
>>> }
>>
>> In "C++'ish" / D way, this is normally dealt like this:
>>
>> int isPrime(int number, int[] /*primesList*/)
>> {
>> //int cnt;
>>
>> return 0;
>> }
>>
>> Hard & ugly? I think warnings are not meant to be used to remember you
>> that you have something unfinished. I regularly tag those parts with "//
>> todo", which is easily grep'd from code.
>>
>
> Warnings are intended to point out things you may have overlooked. 
> Forgetting to finish something certainly qualifies as "overlooked".
>
> I do "//TODO"s as well, but I do it so much that I'm very likely to end up 
> forgetting to finish a partial-implementation before I get around to going 
> through my TODOs and getting to that particular one.
>
> So the problem that inevitably crops up is: When I've commented that stuff 
> out to make my partial implementation compile (so that I can test what 
> I've implemented so far), and then move on to something else and forget to 
> come back to my partial implementation, what's going to happen? It's NOT 
> going to give me a nice noisy warning about "Hey, Mr. Screwup, you're not 
> using this variable!", which *would* have pointed me right back to my 
> unfinished code *before* I got around to that particular "//TODO". So now 
> I have a hidden bug on my hands, just because I've deliberately 
> circumvented the warning system and thereby lost the benefits of having 
> it.
>

In other words, treating warnings as errors (at least if it's all the time) 
or turning warnings into errors creates a need to supress the warnings. And 
in cases like these, supressing them ends up defeating the whole point of 
having them in the first place.





More information about the Digitalmars-d mailing list