Oh nooo! (gotos)

Dave Jones djones at megatest.UUCP
Fri Sep 8 12:03:53 AEST 1989


>From article <1461 at atanasoff.cs.iastate.edu>, by hascall at 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.



More information about the Comp.lang.c mailing list