🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3387

Re: targeted break and continue (was Re: How to eliminate GOTO?)

#3387
From: halasz
Date: Tue, 29 Aug 1995 02:04
28 lines
1751 bytes
In article <41hsls$or@aadt.sdt.com> hawkins@PROBLEM_WITH_INEWS_GATEWAY_FILE (Tony Hawkins) writes
H ....
H   for iLoop: (i=0;i<10;i++)
H     {
H     for(j=0;j<10;j++)
H       {
H       /*  some other code here to set condition */
H       if(condition) break iLoop;
H       } 
H     }

This is nice, and would be just fine, except that it is not obvious hou to
make it work with "do ... while (...);"--label between "while" and "(" also?

In article <m0smnEc-000G1QC@eyrie.demon.co.uk>, Derek Fawcus <df@eyrie.demon.co.uk> writes
D    I quite like this,  esp. if there was an equivalent 'continue iLoop'
D construct available,  such that the label is available to break/continue.
D And yes,  control flow would have to be limited towards outer loops.
If we can make up a distinction between "goto"-labels and theze, the
rest can be handled by scoping: the label is known onlie within the
loop or "switch" (for the latter, of cours, onlie "break").

D ....
D    As it is at the moment,  I usually end up coding constructs like that
D as functions which return true/false values and then doing the
D break/continue based upon the return value.  Unfortunatly this can end
D up making the code harder to follow.
Yeap: this is, in effect, use of "return" for "goto".
Technical Details
Message-ID: <41tsjs$7ss@caip.rutgers.edu>
Path: arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mail
References: <41glno$3a0@caip.rutgers.edu> <41gnhu$qfj@eri2.erinet.com> <m0smnEc-000G1QC@eyrie.demon.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!caip.rutgers.edu!not-for-mail
From: halasz@caip.rutgers.edu
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: targeted break and continue (was Re: How to eliminate GOTO?)
Followup-To: comp.std.c
Date: 28 Aug 1995 22:04:44 -0400
Organization: Rutgers University
Message-ID: <41tsjs$7ss@caip.rutgers.edu>
References: <41glno$3a0@caip.rutgers.edu> <41gnhu$qfj@eri2.erinet.com> <m0smnEc-000G1QC@eyrie.demon.co.uk>
NNTP-Posting-Host: caip.rutgers.edu