Suggested new C loop syntax

John F Carr jfc at athena.mit.edu
Fri Dec 23 18:04:00 AEST 1988


In article <264 at twwells.uucp> bill at twwells.UUCP (T. William Wells) writes:
>This is a bad syntax.
>	do
>		statement
>	while (expr);
>		statement
>
>See the difference? Well, in case you didn't, it is the semicolon at
>the end of the while expression. This is damned hard to spot and does
>not lead to a syntax error.

Do you never use loops in C?  If you do, you are vulnerable to the same
mistake regardless of which variety you use.

  while(expr);
     statement

and

  for(;;);
   
are legal under the current C standard.  I do not see how the proposed 
extension creates any new potential for failure.  

--
   John Carr             "When they turn the pages of history,
   jfc at Athena.mit.edu     When these days have passed long ago,
   bloom-beacon!          Will they read of us with sadness
   athena.mit.edu!jfc     For the seeds that we let grow?"  --Neil Peart



More information about the Comp.lang.c mailing list