Timo Sirainen <[EMAIL PROTECTED]> writes: > On 27.1.2008, at 13.53, Ludovic Brenta wrote: > >> Timo Sirainen writes: >>> for (;;) { >>> } while (xyz); >>> >>> gcc gives no kind of an error or warning. It just ignores the while >>> (). Also >>> tested that this happens with gcc 3.3 and 4.3-20080116-1. >> >> Of course. This is legal C or C++ code consisting of an empty for >> loop followed by an empty while loop. If you think this is a problem, >> switch to Ada. > > Sorry, the indentation messed up my mind.
The language should be designed in such a way that indentation can never mess up ones's mind; and the compiler should detect and report all the stupid errors so you can concentrate on the difficult ones. Consider: for J in Some_Array'Range loop Foo (J); while Some_Condition; -- syntax error ----- for J in Some_Array'Range loop Foo (J); end loop; while Some_Condition; -- syntax error ----- for J in Some_Array'Range loop Foo (J); end loop; while Some_Condition loop end loop; -- syntax error ----- for J in Some_Array'Range loop Foo (J); end loop; while Some_Condition loop null; end loop; -- OK, finally Yes, in Ada you must say so when a loop is intentionally empty! And the resulting program, after scrutiny by the compiler, obeys the Law of Least Astonishment. -- Ludovic Brenta. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]