[net.lang.c] break <label> != goto <label>

trough@ihuxi.UUCP (Chris Scussel) (01/10/85)

There seems to be some confusion on the suggested "break <label>" construct.
I believe the suggestion is:

		label: for ( ... )
			{
				...
				break label ;
				...
			}

Some folks apparently interpreted the suggestion as meaning

			for ( ... )
			{
				...
				break label ;
				...
			}
		label:	...

which does differ from a vanilla goto, but not by much.
I believe that the first interpretion is both nicely structured and useful.
The "break" is associated with the construct it breaks by the label,
so the suggestion is relatively robust in the face of code changes,
unlike "break <n>", "goto <n>", and the alternate interpretation
of "break <label>".

	I must admit that when I first heard of this a couple of years
back I also misinterpreted it to be not much more than a goto. When
it was explained to me what was really meant I became an instant convert,
and have liked it ever since. (Just for fun, I added it to a C interpreter
I had written. It was trivial.)

				Chris Scussel
				AT&T Bell Labs
				ihnp4!ihuxi!trough

henry@utzoo.UUCP (Henry Spencer) (01/13/85)

Putting the label at the beginning of the loop, when the "break <label>"
transfers to the end of the loop, strikes me as poor design.  One can
argue that the label ought to appear in both places to make the bracketing
clear, but now we're back to a situation where goto can solve the problem
just about as well.

Personally, my favorite loop-exit construct is "return".
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry