Labelled breaks and continues

Stuart Friedberg stuart at rochester.UUCP
Thu Aug 25 14:32:04 AEST 1983


From: Stuart Friedberg  <stuart>
I disagree with chongo about the 'cleanness" of labelled break and
continues, so long as they only go to the end or beginning of enclosing
blocks. That means they are *not* as general as gotos.

>From the 'theoretical' standpoint it has been shown that labelled break
and continues are strictly more expressive than the original constructs
for "structured programming", the conditional and the loop (while and/or
repeat). You get this additional expressive power *without* generating
any irreducible flowgraphs, which correspond to gotos into a loop or
straightline code block. Reference is "A Comparison of Multilevel Break
and Next Statements", Brenda S. Baker & S. Rao Kosaraju, Journal of the
Association for Computing Machinery, Volume 26, Number 3, July 1979, 
pp 555-566.

They are *very* easy to implement. I did a compiler for a language using
them (BABBAGE) for a course last year. (No, this is not the same Babbage
as was written up in Datamation last year!) You know immediately upon
seeing the break or continue whether or not it references a legal label
or not. You can even do the forward references (for breaks) in one pass.

I find them an extremely handy thing to have around. They take care of
just about any exceptional conditions that you might reasonably use a
goto for, without the uncontrollable character of the goto.

					Stu Friedberg
				{seismo, allegra}!rochester!stuart
					stuart at rochester



More information about the Comp.lang.c mailing list