🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3504

Re: Multi-level break and elimination of GOTO

#3504
From: Fredrik Bredberg
Date: Mon, 27 Nov 1995 09:38
70 lines
3830 bytes
In article <6495326.71820.1619@kcbbs.gen.nz> martin@kcbbs.gen.nz
(Martin Kealey) writes:

[snip]

> It is a new contruct, and therefore doesn't yet have a "natural spot".
> Putting the "label" of the loop *before* it doesn't strike me as a
> particularly natural place since the result of a break is to jump *after*
> the loop.  I would argue that putting the name next to the loop exit
> condition is the most natural place for it, but that's just my opinion.
> 
> Perl & Java don't have to cope with the ambiguity of a goto label, so they
> are free to re-use the "label :" format.
> 
> PLEASE EVERYONE READ THIS:
> 
> The point of creating a new grammatical form for loop names is to ENSURE
> (1) that they CAN'T become the target of a goto, and
> (2) a later maintainer can see that simply by looking at the loop control -
>     without having to go searching for a break or continue to know that
>     it is a loop name rather than a goto label.
> 
> Since we would be modifying the grammar for one part of the language (break
> and continue) there is little point in arguing against modifications
> elsewhere, since they'll both be introduced simultaneously.

I can't agree more...

> My opinion is that this should be further strengthened - a loop should be
> able to have multiple names, but each name must be used exactly once,

So far so good...

> unless a second grammatical form is used to introduced a
> "multi-reference" name (say a double colon?).

Like this?

for loop ( i = 0 ; i < 10 ; i++) /* outer loop */
{
    for loop ( i = 0 ; i < 10 ; i++) /* inner loop */
    {

        if (cond)
            break ::xyz; /* break outer loop */
    }
}

We then have to introduce the scooping-operator ``::'', and believe me;
people will then want to use that for more than just break and continue.

I don't think it's a good idea to let the language promote such
naming- ambiguities. Nested loop-names should be unambiguous and the
compiler should spank you if there aren't.

-- 
+---------------------------+------------------------------------------------+
| Fredrik Bredberg          |                                                |
| E-Mail..: frbr@enea.se    |                                                |
| Pager...: + 46 746 457371 |         Legally    - It's questionable         |
| Enea Tel: + 46 8 6385067  |         Morally    - It's disgusting           |
| Enea Fax: + 46 8 6385050  |         Personally - I like it!                |
| EUA User: konfrbr         |                                                |
| EUA  Tel: + 46 8 7273638  |                                                |
+---------------------------+------------------------------------------------+
|   o       a     Do bear in mind  that the opinions expressed  in this mail |
|   H-+-- \/#\    are my own and that they don not necessarily represent the |
|  / )      |\    opinions of my  employer or any of my  employer's clients. |
+----------------------------------------------------------------------------+
Technical Details
Message-ID: <rnb4tvqcs8u.fsf@euax7i3c01.eua.ericsson.se>
Path: arc1-ca.pugleaf.net!eua.ericsson.se!usenet
References: <486cj7$o4s@news.mel.aone.net.au> <48bpa2$lmf@news.mel.aone.net.au> <m0tFpAH-000FeXC@eyrie.demon.co.uk> <490b59$3qt@panix.com> <491cb0$7dp@spool.cs.wisc.edu> <6495326.71820.1619@kcbbs.gen.nz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!eua.ericsson.se!usenet
From: konfrbr@euax7i3c01.eua.ericsson.se (Fredrik Bredberg)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: Multi-level break and elimination of GOTO
Date: 27 Nov 1995 10:38:09 +0100
Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
Sender: konfrbr@euax7i3c01.eua.ericsson.se
Message-ID: <rnb4tvqcs8u.fsf@euax7i3c01.eua.ericsson.se>
References: <486cj7$o4s@news.mel.aone.net.au>
 <48bpa2$lmf@news.mel.aone.net.au> <m0tFpAH-000FeXC@eyrie.demon.co.uk>
 <490b59$3qt@panix.com> <491cb0$7dp@spool.cs.wisc.edu>
 <6495326.71820.1619@kcbbs.gen.nz>
NNTP-Posting-Host: euax7i3c01.eua.ericsson.se
In-reply-to: martin@kcbbs.gen.nz's message of 23 Nov 95 19:57:00 GMT
X-Newsreader: Gnus v5.0.4