Super Lint

Lutger lutger.blijdestijn at gmail.com
Wed Sep 20 16:42:35 PDT 2006


Walter Bright wrote:
> Ivan Senji wrote:
>> But is it safe do declare the above example as a bug? Maybe that break 
>> is placed there to see what just one pass of the loop does (maybe for 
>> debugging purposes).
> 
> That certainly is the question. I don't think I'd want to see such code 
> in released source, but:
> 
> 1) is it legitimate for debug/test code?
> 2) can it come about as the side effect of some other coding pattern?
> 3) if it is made illegal, is that going to be a bigger problem than it 
> solves?
> 4) does it really solve a problem?
> 
> For example, it could happen with (example found on the internet):
> 
>     for (int i = 0; i < 10; i++)
>     {
>         if (condition)
>             action();
>             break;
>     }
> 
> where the user forgot to put { } around the else clause. It's sort of 
> like how:
> 
>     for (int i = 0; i < 10; i++);
>     {
>         ...
>     }
> 
> is illegal in D (note the ; after the closing parenthesis). I've known 
> people to spend many hours trying to track down this nearly invisible bug.

I think this a great idea. The for loop example is one of the so-called 
incremental improvements in D that saved me quite some time vs C++. I 
almost forgot how annoying it is to spend time on hunting for bugs that 
are just typo's.
It's very reasonable for such a tool imho to demand debug code that is 
otherwise a bug be written with debug version statements, thus I don't 
see the debug argument as a con.



More information about the Digitalmars-d mailing list