Article View: comp.std.c
Article #3384Re: How to eliminate GOTO?
From: mag
Date: Mon, 28 Aug 1995 02:52
Date: Mon, 28 Aug 1995 02:52
34 lines
1399 bytes
1399 bytes
In article <41pm80$skp@inferno.mpx.com.au>, msmith@jolt.mpx.com.au (Michael Smith)says...
>
>Much of the discussion on got vs loop tests comes down to a matter of
>taste. My own rule of thumb is that if a "goto" must be used, the goto
>and the label should be visible on the same screen. If it is necessary for
>a programmer to go searching for the label then you have the beginnings
>of spagetti code.
>
One of the excellent uses of goto is to force a single exit point for a function.
int ISomefunction(int iSomeArg)
{
int iRetVal = 0;
if (iSomeArg < 20)
{
iRetVal = 1;
goto L_Return;
}
...
...
...
L_Return :
return(iRetVal);
}
--
MAG
/* ********************************************************
To understand recursion one must first understand recursion
******************************************************** */
Technical Details
Message-ID:
<DE02nC.B58@eskimo.com>Path:
arc1-ca.pugleaf.net!in1.uu.net!eskimo!newsReferences:
<3vn1ht$kj8@martha.utk.edu> <41cke4$gtd@sparcserver.lrz-muenchen.de> <41glno$3a0@caip.rutgers.edu> <41iebe$kec@news0.rain.rg.net> <41pm80$skp@inferno.mpx.com.au>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c Path: arc1-ca.pugleaf.net!in1.uu.net!eskimo!news From: mag@eskimo.com (mag) Subject: Re: How to eliminate GOTO? X-Nntp-Posting-Host: tia1.eskimo.com Message-ID: <DE02nC.B58@eskimo.com> Sender: news@eskimo.com (News User Id) Organization: *.* X-Newsreader: WinVN 0.93.10 References: <3vn1ht$kj8@martha.utk.edu> <41cke4$gtd@sparcserver.lrz-muenchen.de> <41glno$3a0@caip.rutgers.edu> <41iebe$kec@news0.rain.rg.net> <41pm80$skp@inferno.mpx.com.au> Mime-Version: 1.0 Date: Mon, 28 Aug 1995 02:52:24 GMT