gotos

Peter J Desnoyers peter at athena.mit.edu
Wed May 4 08:55:16 AEST 1988


In article <490 at sas.UUCP> bts at sas.UUCP (Brian T. Schellenberger) writes:
>(I would, however, support "break loop" for the special case of breaking out
>of a while/do/for loop from inside of a nested "switch".  I find the inability
>to get out of there cleanly very annoying.)
>-- 
>                                                         --Brian.
>(Brian T. Schellenberger)				 ...!mcnc!rti!sas!bts

I would consider the semantics of the switch statement to be the worst
botch in the C language, obviously induced by reading lots of
assembler code. Not to say that it's horrible, or anything, but 95% of
the time I use a switch statement I don't use cases that fall through;
whereas I find myself wishing I could use a switch to figure out how
to break out of a loop a lot more than 5% of the time. (So far I've
used gotos for this.) I would rather that the switch construct was
used in the following way:

   switch (n)
   {
     case foo:
       statement_or_block
     case bar:
   }

rather than overloading 'break' with two different meanings - one for
switches, and another for do, while, and for loops.  I would accept
the use of 'continue' to fall through, even though the net aesthetic
improvement would be zero. Of course, we can't change it now, and it's
not too broken to use by any means...

				Peter Desnoyers
				peter at athena.mit.edu



More information about the Comp.lang.c mailing list