Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site randvax.UUCP
Path: utzoo!linus!philabs!cmcl2!seismo!hao!hplabs!sdcrdcf!randvax!jim
From: jim@randvax.UUCP (Jim Gillogly)
Newsgroups: net.lang.c
Subject: Re: Breaking out of several nested loops (& ANSI C)
Message-ID: <2052@randvax.UUCP>
Date: Thu, 11-Oct-84 11:18:33 EDT
Article-I.D.: randvax.2052
Posted: Thu Oct 11 11:18:33 1984
Date-Received: Sat, 13-Oct-84 08:46:23 EDT
References: <129@ssc-vax.UUCP> <1801@pegasus.UUCP> 
Reply-To: randvax!jim
Organization: Rand Corp., Santa Monica
Lines: 29
Keywords: break label

--------------
Breaking out of a nested loop with a "break label" instead of a GOTO is
supposed to be much better for program verification.  Rather than being an
arbitrary control transfer, it merely exits from a well-defined
environment.  At least that's what Bill Wulf told us when he invented it
for BLISS.

The only time I use GOTO's in C is to get out of these loops, and I write
a whole lot of C.

I heartily concur with David Dyer-Bennett's assertion that "break label"
is much better than "break n", having used and tried to debug with both
in BLISS.  I would add an outer loop now and then and forget that there
was an "exitloop 3" on the next screen.

For stand-alone completeness, we're talking about leaving nested loops as
follows:

     label:
	for (i = 0; i < n; i++)
	{       ...
		for (j = 0; j < m; j++)
		{       ...
			if (error)
				break label;
		}
	}

Jim Gillogly            {vortex, decvax}!randvax!jim