using break <label> instead of goto <label>

Mike Lutz mjl at ritcv.UUCP
Fri Jan 11 08:56:27 AEST 1985


> ...  Putting in a "break" statement which
> acts exactly like "goto" but which is only accepted by the compiler in certain
> contexts doesn't really add anything to the power of the language.
> 
> 	Guy Harris

I disagree with Guy on this one (exceedingly dangerous, if you know
what I mean, and I think you do :-).  If indeed the break <label> is
added so that a) the <label> must be associated with a control construct in
which the break is nested and b) causes execution to start with the
first statement following this construct, then indeed it is different
from (and, I argue, a useful alternative to) goto <label>.  Guy is
right - break <label> does not extend the power of the language; if
anything, it limits it (or, better yet, controls it).

The altered semantics *are* important.  Sure, the documentation effects
can be achieved by strict adherence to programming conventions and the
use of a #define like the one Guy proposed.  However, the error
detection possibilities are every bit as important (I vaguely remember
making an error long ago), and the limited form of goto can turn
difficult to diagnose run-time errors into compile-time errors.

All of this ignores, of course, any assessment of the problems of
incorporating this facility in C relative to its worth.  I've no
illusions about the difficulty, especially when you realize that all
labels are potential targets of a goto but some are also possible
referents of the new break.  But I was addressing the absolute utility
of the construct, rather than its relative utility when considering
the engineering problems of such a retrofit.
-- 
Mike Lutz	Rochester Institute of Technology, Rochester NY
UUCP:		{allegra,seismo}!rochester!ritcv!mjl
CSNET:		mjl%rit at csnet-relay.ARPA



More information about the Comp.lang.c mailing list