🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3373

Re: How to eliminate GOTO?

#3373
From: Tony Hawkins
Date: Thu, 24 Aug 1995 12:52
39 lines
1750 bytes
Jerone A. Bowers (jab@PROBLEM_WITH_YOUR_MAIL_GATEWAY_FILE) wrote:
> halasz@caip.rutgers.edu wrote:
> : 
> :      iLoop: for(i=0;i<10;i++)
> :        for(j=0;j<10;j++){
> :          /*  some other code here to set condition */
> :          if(condition) break iLoop;
> :        } 


>   	for(i=0;i<10;i++)
>            for(j=0;j<10;j++)
> 	   {
>                    /*  some other code here to set condition */
>               if(condition) goto iLoop;
>            }
>     iLoop:
>       .....

> Pretty much the same thing are they not?  

Well, both have the same drawback (I prefer the first though). 
The problem is that when confronted with maintaining someone
elses code, a *very thorough* examination of the code surrounding 
either of these constructs is required.  Why?  Because there is no
*structure* to show that there are no other gotos which target iLoop
randomly sprinkled around!  Whats needed is a construct which 
clearly limits the 'scope' of the label to within the outer loop
and to breaks only.  Something like the following:


   for iLoop: (i=0;i<10;i++)
     {
     for(j=0;j<10;j++)
       {
       /*  some other code here to set condition */
       if(condition) break iLoop;
       } 
     }
Technical Details
Message-ID: <41hsls$or@aadt.sdt.com>
Path: arc1-ca.pugleaf.net!aadt.sdt.com!hawkins
References: <3vn1ht$kj8@martha.utk.edu> <41cke4$gtd@sparcserver.lrz-muenchen.de> <41glno$3a0@caip.rutgers.edu> <41gnhu$qfj@eri2.erinet.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!aadt.sdt.com!hawkins
From: hawkins@PROBLEM_WITH_INEWS_GATEWAY_FILE (Tony Hawkins)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: How to eliminate GOTO?
Date: 24 Aug 1995 12:52:12 GMT
Organization: SABRE Decision Technologies
Message-ID: <41hsls$or@aadt.sdt.com>
References: <3vn1ht$kj8@martha.utk.edu> <41cke4$gtd@sparcserver.lrz-muenchen.de> <41glno$3a0@caip.rutgers.edu> <41gnhu$qfj@eri2.erinet.com>
NNTP-Posting-Host: 144.9.233.182
X-Newsreader: TIN [version 1.2 PL1]