for in D versus C and C++

BCS ao at pathlink.com
Thu Mar 19 10:51:26 PDT 2009


Reply to Walter,

> 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:
> 

Um, that's not what I was referring to. The problem the OP referenced seems 
trivial enough to me: I try to compile my translated code and get a nice 
error

Line 3: use '{ }' for an empty statement, not a ';'

I jump to that line, figure out if it was a bug in the original C code or 
if it is supposed to be that way and and fix it





More information about the Digitalmars-d mailing list