Breaking out of several nested loops (& ANSI C)

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Tue Oct 16 10:25:16 AEST 1984


Gee, I thought everyone knew that the most general structured loop is
	startloop
		...
		on condition (...) leaveloop
		...
	repeatloop
which can mimic a "while" or "do .. while" loop if one or the other
of the body sections is null.  The rules for "structuredness" seem
to be: a loop invariant is being maintained (and is stated EXPLICITLY,
perhaps in a comment), the loop is entered at the top, and there is
only one exit from the loop.  C's "break" and "continue" violate this
just as much as a "goto" would.  But so what; a conscientious
program designer will "think structured" no matter what language he
is using.  I have yet to see an automated tool (including ADA) for
enforcing proper programming practice that can compensate for ignorance
or stupidity on the part of its user.



More information about the Comp.lang.c mailing list