🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3462

Re: Multi-level break and elimination of GOTO

#3462
From: Erik Corry
Date: Wed, 08 Nov 1995 02:07
40 lines
2100 bytes
Fredrik Bredberg (konfrbr@euax7i3c01.eua.ericsson.se) wrote:
: Andrew Dunbar (andrewd@agnus.livewire.com.au) wrote:
: :
: : 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);
: :    }
: : }

: I think that Andrew's `named' loops is the best alternative to this
: problem that I'v seen so far! The main reason for this is that the
: `label' is so closely coupled to the loop constructor.

What I think is wrong with 'named loops':

1) It's a completely new syntax for C. This makes learning it difficult.
2) It's a completely new syntax for C. This makes parsing it difficult.
   Specifically it looks like a function call inner() yet it is actually
   a label. Major grief for the lexer/parser interface. So at a minmum
   there should be a ':' after the label to help the lexer. If you
   do that why not swap the order of the label and the for/while token
   and do it like Java!
3) It gains us virtually nothing. Remember we can't get rid of goto!
   So we are introducing a new construct that duplicates things that
   can be done with goto.

The only benefit would be better error checking, because 'break <label>'
can be used in fewer situations than 'goto <label>'. But what sort of
errors can we catch with this construct?

1) Do it like Java.
2) Leave it as it is.

--
Erik Corry ehcorry@inet.uni-c.dk
Technical Details
Message-ID: <DHpCK1.HyG@kroete2.freinet.de>
Path: arc1-ca.pugleaf.net!kroete2.freinet.de!erik
References: <43pdut$hoh@galaxy.csc.calpoly.edu> <DF8FE3.97H@news.cern.ch> <rnbohuqj8p3.fsf@euax7i3c01.eua.ericsson.se>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!kroete2.freinet.de!erik
From: erik@kroete2.freinet.de (Erik Corry)
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: Wed, 8 Nov 1995 02:07:12 GMT
Organization: Home
Sender: news@kroete2.freinet.de (news)
Message-ID: <DHpCK1.HyG@kroete2.freinet.de>
References: <43pdut$hoh@galaxy.csc.calpoly.edu> <DF8FE3.97H@news.cern.ch> <rnbohuqj8p3.fsf@euax7i3c01.eua.ericsson.se>
Reply-To: ehcorry@inet.uni-c.dk (Erik Corry)
NNTP-Posting-Host: arhppp12.uni-c.dk
X-Newsreader: TIN [version 1.2 PL2]