🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3425

Re: Multi-level break and elimination of GOTO

#3425
From: Maurizio Loreti
Date: Thu, 21 Sep 1995 02:42
35 lines
2185 bytes
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);
>      }
>   }

You are not the first one to submit this suggestion; however it is, in
my humble opinion, very bad indeed.  Consider: if you will add
tomorrow another loop around the break, will you remember to change
break(2) to break(3) ?  And another programmer, looking at the code,
how can know where the "target of the break" is?  Counting braces? 
Not easy...  Relying on the indentation?  Impossible...  To have a
clear indication of where exactly a break(n) jumps, would it not be
better to write it "break <label>"?  And what is that construct?  A
GOTO WITH A DIFFERENT NAME.  Well, my english is quite terrible and I
will not dare to cite Shakespeare - but if you have a rose and call it
with another name, will not have the same smell?  Concluding, learn to
live with goto's; altough rarely used, from time to time you will find
that a goto makes the code clearer - also Mr. K. and Mr. R. in their
K&R book aknowledge that...  did you read that page?

Maurizio Loreti                       http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
Un. of Padova, Dept. of Physics - Padova, Italy          loreti@padova.infn.it
Technical Details
Message-ID: <DF8FE3.97H@news.cern.ch>
Path: arc1-ca.pugleaf.net!axcdf1.pd.infn.it!LORETI
References: <43pdut$hoh@galaxy.csc.calpoly.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c
Path: arc1-ca.pugleaf.net!axcdf1.pd.infn.it!LORETI
From: loreti@axcdf1.pd.infn.it (Maurizio Loreti)
Subject: Re: Multi-level break and elimination of GOTO
X-Nntp-Posting-Host: axcdf1.pd.infn.it
Message-ID: <DF8FE3.97H@news.cern.ch>
Sender: news@news.cern.ch (USENET News System)
Reply-To: loreti@axcdf1.pd.infn.it
Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
References: <43pdut$hoh@galaxy.csc.calpoly.edu>
Date: Thu, 21 Sep 1995 02:42:01 GMT