Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!ames!claris!sts!cohesive!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: Oh nooo! (gotos) Message-ID: <7817@goofy.megatest.UUCP> Date: 8 Sep 89 02:03:53 GMT References: <1461@atanasoff.cs.iastate.edu> Organization: Megatest Corporation, San Jose, Ca Lines: 45 From article <1461@atanasoff.cs.iastate.edu>, by hascall@atanasoff.cs.iastate.edu (John Hascall): ... > I have often wished for something similar, my thoughts have tended toward > the synatx: > > continue [constant-integer-expression]; > break [constant-integer-expression]; > > where the [optional] expression indicated how many nested structures > to continue or break, with the default being 1 (just like the current > "continue" and "break"). > I like named blocks better. If you explicitly say how many levels to exit, you will have trouble if you add or remove a level during development or maintenence. Besides, the reader, or even the developer, may miscount the levels. At T.I. back in the seventies, I worked on and with a languages called TIP and MPP, both Pascal variants. They had this sort of thing: loop: while expr do loopbody: begin ... if finished_with_this_iteration do escape loopbody; ... if finished_with_loop do escape loop; end; Notice that the "escape loopbody" is equivalent to a continue-statement. The nested scope rules even allowed you to escape from a parent procedure. I actually used that feature once to do a sort of "structured longjmp". That was in a program for controlling an oil platform. No kidding. Sure hope I did it right.