Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site callan.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!hao!hplabs!sdcrdcf!trwrb!scgvaxd!wlbr!callan!tim
From: tim@callan.UUCP (Tim Smith)
Newsgroups: net.lang.c
Subject: Re: "break " vs. "goto "
Message-ID: <289@callan.UUCP>
Date: Sat, 12-Jan-85 15:55:54 EST
Article-I.D.: callan.289
Posted: Sat Jan 12 15:55:54 1985
Date-Received: Mon, 21-Jan-85 04:31:47 EST
References: <7096@brl-tgr.ARPA> <7121@brl-tgr.ARPA> <1076@hcrvx1.UUCP>
Reply-To: tim@callan.UUCP (Tim Smith)
Organization: Callan Data Systems, Westlake Village, CA
Lines: 46
Summary:
Turnh on :-) mode.
In the two methods for breaking loops:
/* /*
* Method A * Method B
*/ */
loop: while ( foo ) while ( foo )
{ {
. .
. .
break loop; goto endloop;
. .
} }
endloop:;
many people seem to prefer A, because the label is at the start of the
loop, rather than at the end of the loop.
It seems to me that the obvious thing to do is to change the goto statement.
Goto should have the form
goto label [ {+,-} constant_expression ] ;
The constant expression tells how many statements away from the label
to 'goto'. For example, the while loop break would be written like this:
/*
* Method C
*/
loop: while ( foo )
{
.
.
goto loop + 1;
.
}
Exit :-) mode
How are 'do' loops to fit in with 'break label'?
Does the 'label' go with the 'do' or the 'while'?
--
Duty Now for the Future
Tim Smith
ihnp4!wlbr!callan!tim or ihnp4!cithep!tim