My new favorite D feature
Walter Bright
newshound at digitalmars.com
Fri Dec 22 22:36:48 PST 2006
Tim Keating wrote:
> At least for then next couple of hours, anyway:
>
> int i = 100;
>
> if (i = 2);
> {
> writefln("We shouldn't be here");
> }
>
> Yields:
>
> use '{ }' for an empty statement, not a ';'
>
> Instead of blithely steping into that block. As just happened in my C++
> program, wasting 30 minutes of my life while I tried to figure out why
> the heck that block kept getting executed.
That feature is in there, because way back in 1984 or so, a friend of
mine (who is a top programmer) spent several hours with code that looked
like:
... statements ...
for (i = 0; i < n; i++);
{
... statements ...
}
... statements ...
wondering why his loop executed exactly once.
More information about the Digitalmars-d
mailing list