Article View: comp.std.c
Article #3383targeted break and continue (was Re: How to eliminate GOTO?)
From: Derek Fawcus
Date: Sun, 27 Aug 1995 19:28
Date: Sun, 27 Aug 1995 19:28
30 lines
1630 bytes
1630 bytes
In article <41hsls$or@aadt.sdt.com> hawkins@PROBLEM_WITH_INEWS_GATEWAY_FILE (Tony Hawkins) writes:
> 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;
> }
> }
I quite like this, esp. if there was an equivalent 'continue iLoop'
construct available, such that the label is available to break/continue.
And yes, control flow would have to be limited towards outer loops.
If these were available, then we could have 'break label' from
switch/for/while, and 'continue label' from for/while.
As it is at the moment, I usually end up coding constructs like that
as functions which return true/false values and then doing the
break/continue based upon the return value. Unfortunatly this can end
up making the code harder to follow.
DF
--
Derek Fawcus (G7FVS) df@eyrie.demon.co.uk
Technical Details
Message-ID:
<m0smnEc-000G1QC@eyrie.demon.co.uk>Path:
arc1-ca.pugleaf.net!mail2news.demon.co.uk!eyrie.demon.co.ukReferences:
<41glno$3a0@caip.rutgers.edu> <41gnhu$qfj@eri2.erinet.com> <41hsls$or@aadt.sdt.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!eyrie.demon.co.uk From: Derek Fawcus <df@eyrie.demon.co.uk> Newsgroups: comp.std.c,comp.lang.c Subject: targeted break and continue (was Re: How to eliminate GOTO?) Date: Sun, 27 Aug 1995 19:28:19 GMT Organization: The Phoenix's Nest Message-ID: <m0smnEc-000G1QC@eyrie.demon.co.uk> References: <41glno$3a0@caip.rutgers.edu> <41gnhu$qfj@eri2.erinet.com> <41hsls$or@aadt.sdt.com> X-NNTP-Posting-Host: eyrie.demon.co.uk X-Broken-Date: Sun, 27 Aug 95 20:19 BST