BCS wrote:
Thu, 19 Mar 2009 06:35:37 -0400, Steve Teale wrote:

for (; a<b; a++);

is illegal in D.

Doesn't this break a lot of C and C++ code?

for (; a<b; a++) {}

is legal.  I don't think that an empty statement after for is used in
"a lot of code."


it's a trivial fix and easy to find. Heck, you hardly need to think!

No, it isn't easy to find. This is in D because a colleague of mine, who was an expert C programmer (the best in the company I was working for), came to me with:

for (xxx; i < 10; i++);
{
     ... code ...
}

and said he could not figure out why his loop executed only and exactly once. He'd fiddled with it for a whole afternoon. He said he must be missing something obvious. I said you've got an extra ; after the ). He smacked his head and about fell over backwards.

So it's illegal in D, along with:

   if (condition);

and similar constructs. Have to use a { } to indicate a blank statement.

Reply via email to