Break and Goto (yet another solution)

Jeff ROWE at RU-BLUE.ARPA
Tue Jan 22 12:17:20 AEST 1985


	I know this topic may be getting old and perhaps sore, but
after I had mentioned it to a couple of friends of mine, I was surprised
that they suggested the same thing that I had thought of.  So, now I am
wondering if it really has any merit or not.
	The solution is not as general as the break label, but really
should suffice for most uses.  We seem to think that the problem seen
most is when one would like to place a switch inside a while and use
the break to get out the while and not just the switch.  This leads
us to suggest having a construct break <statement type>, where
statement type includes while and for etc.  There are no labels and
where it breaks to is the same as break now (i.e. to the statement
following the contruct broken).  Since this is recognizing tokens
already reserved and because of its "limited scope" it might also
be simpler to implement.
	Of course the standards group might still not be interested
in any enhancements, but if that is really true, most of the talk
on this bboard is rather pointless.
	I'd be interested to know what people think of this idea
though even if you send me mail directly instead of using the
list.
				Jsr
				rowe at rutgers

Our example follows in case it was unclear above...

	while (...) {
		switch (...) {
		case A:
			...;
			break; /* normal break of switch */
		case B:
			...;
			break while; /* get out of the loop */
		default:
			...;
			break switch; /* verbose regular break */
		} /* switch */
	} /* while */

Of course other constructs can have similar solutions as long as
you dont try to break out of nested constructs of the same
statement type.
-------



More information about the Comp.lang.c mailing list