"break <label>" vs. "goto <label>"

Tracy Tims tracy at hcrvx1.UUCP
Sat Jan 12 01:47:57 AEST 1985


>> Yuck!  "break <n>;" is an accident looking for a place to happen!
>> If one has to have this facility, "break <label>;" is far superior.

> And "goto <label>" is even better, you don't have to change the language
> at all.

In "break <label>;" the label is used to identify the control structure being
exited, rather than the place being exited to.  It is more robust in terms of
future program changes, and it has the advantage of being defined only in terms
of structured constructs.

	loop1:	while ( <cond1> ) {
			.
			.
		while ( <cond2> ) {
			.
			break loop1;
			.
		}
			.
			.
	}

                              Tracy Tims    {linus,allegra,decvax}!watmath!...
   Human Computing Resources Corporation                     {ihnp4,utzoo}!...
 Toronto, Ontario, Canada.  416 922-1937                   ...hcr!hcrvx1!tracy



More information about the Comp.lang.c mailing list