Yet Another Break Statement - (nf)

notes at ucbcad.UUCP notes at ucbcad.UUCP
Thu Oct 6 16:12:48 AEST 1983


#N:ucbesvax:4800024:000:1260
ucbesvax!turner    Sep  6 04:03:00 1983

A pet peeve of mine about "break" is that, as long as they were going to
special-case some existing keyword for switch statements, why the @*%$!
wasn't it "continue"?  Why didn't they make "break" the DEFAULT action in
cases, and instead use "continue" for forcing fall-through?  E.g.,

	switch (thing) {
	    case 0:	...
					/* (exit switch) */
	    case 1:	...
			continue;	/* (force fall-thru) */
	    case 2:	...
	    }

On the multi-level break issue: wouldn't a "break all the way out" handle 99%
of this 2% problem?  I think "break n levels out" is confusing, and "break or
continue to label" is only slightly better.  Really.  Gag me with a flowchart.

Beyond this, I'd like a "broken" clause for loops, on the assumption that most
break's mean abnormal loop termination.  Nice, for those common situations in
which normality is at the end of the outermost loop, and "fubar" is just after.

{
	...
	for (...) {
		... {
			... {
			    breakout;	/* deep fubar! */
			} ...
		} ...
		break;			/* shallow fubar */
	    }
	broken {	/* "for" was broken out of, */
		... 	/* so do fubar processing */
	    return;
	    }
	...		/* wrap up normally */
	return;		/* only if loop exhausted */
}

Too late now, I guess.

	Michael Turner (ucbvax!ucbesvax.turner)



More information about the Comp.lang.c mailing list