Proposal for breaking out of multiple loops

DAVID DYER-BENNET MRO1-2/L14 DTN 231-4076 ddb at mrvax.DEC
Thu Oct 11 00:51:56 AEST 1984


This is an extremely valuable feature; its use makes for much more
readable, structured, code than anything except the "goto" approach, and
it is clearly superior to that as well (just not as much).

The proposed method, assigning a "label" to a block of code and then saying
"break label;" to break out of that block, is exactly the correct way of
doing it, in my opinion.  Bliss has such a feature, which I have used,
and find quite useful.

There is another way of doing it, brought to mind by calling this a "break n"
capability.  This way of doing it is, in my opinion, WRONG WRONG WRONG!  The
older Bliss-10 language had an "exitloop n" construct where n was the number
of enclosing loops you were going to exit from.  First, this was hard to read,
because you had to carefully find all the loops, and count them.  Far worse,
however, was that the addition of another loop surrounding the code in
question could cause it to become invalid!!!  Obviously, this gets worse
very rapidly (exponentially?) as the value of n increases.

So, my vote:  "Break label"  Yes Yes Yes
	      "Break n"	     No  No  No

			-- David Dyer-Bennet
			-- ...decwrl!dec-rhea!dec-mrvax!ddb



More information about the Comp.lang.c mailing list