🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3459

Re: Multi-level break and elimination of GOTO

#3459
From: Andrew Dunbar
Date: Sat, 04 Nov 1995 00:13
41 lines
1730 bytes
Maurizio Loreti (loreti@axcdf1.pd.infn.it) wrote:
: In article <43pdut$hoh@galaxy.csc.calpoly.edu>, awozniak@galaxy.csc.calpoly.edu (Hey Sister can you spare a hug?) writes:
: >Since I haven't seen this suggested yet, I'll throw it in and see what
: >happens...
: >
: >It seems (to me) that one of the most needed places for a goto is inside a
: >multiply nested for or while loop of some sort.  I have often wished for a
: >multi-level break statement in cases like this:
: >...
: >
: >   for (x = 0; x < MAXX; x++)
: >   {
: >      for (y = 0; y < MAXY; y++)
: >      {
: >         if (map[y][x] == '*')
: >            break(2);
: >      }
: >   }
: 

Has anyone thought of the possibility of 'named' loops?

for outer (x = 0; x < MAXX; x++)
{
   for inner (y = 0; y < MAXY; y++)
   {
      if (map[y][x] == '*')
         break (outer);
   }
}

As far as I can see this would not cause any ambiguities, is logical, extensible,
and fun for all ages :)

I thought of this about a week or two ago while pondering this problem and as I am 
currently playing with C parsing, I might try to implement it in a grammar.

Does anyone have any thoughts on this idea?

Andrew Dunbar
GPSoftware
Technical Details
Message-ID: <47eb7k$ckb@news.mel.aone.net.au>
Path: arc1-ca.pugleaf.net!news.mel.aone.net.au!not-for-mail
References: <43pdut$hoh@galaxy.csc.calpoly.edu> <DF8FE3.97H@news.cern.ch>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.mel.aone.net.au!not-for-mail
From: andrewd@agnus.livewire.com.au (Andrew Dunbar)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: Multi-level break and elimination of GOTO
Followup-To: comp.std.c,comp.lang.c
Date: 4 Nov 1995 00:13:40 GMT
Organization: Livewire Communications
Message-ID: <47eb7k$ckb@news.mel.aone.net.au>
References: <43pdut$hoh@galaxy.csc.calpoly.edu> <DF8FE3.97H@news.cern.ch>
NNTP-Posting-Host: agnus.livewire.com.au
X-Newsreader: TIN [UNIX 1.3 950515BETA PL0]