for in D versus C and C++
Ary Borenszweig
ary at esperanto.org.ar
Thu Mar 19 10:35:30 PDT 2009
BCS wrote:
> Hello Sergey,
>
>> 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!
It's not easy to find. I didn't understand why that "for" was illegal
until I saw Alexander Pánek's second answer and noticed there was a
semicolon. I didn't understand why "for (; a<b; a++)" was wrong. :-P
More information about the Digitalmars-d
mailing list