🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3502

Re: Multi-level break and elimination of GOTO

#3502
From: Martin Kealey
Date: Thu, 23 Nov 1995 19:57
49 lines
2839 bytes
In article <491cb0$7dp@spool.cs.wisc.edu>,
 Shaun Flisakowski (flisakow@fontina.cs.wisc.edu) wrote:
> >In article <m0tFpAH-000FeXC@eyrie.demon.co.uk>
>   Derek Fawcus <df@eyrie.demon.co.uk> writes:
...
> >>Simply,  the optional loop name is _preceeded_ by a colon.  Wouldn't
> >>this also remove the ambiguity on the 'do ... while' as the colon comes
> >>before the name.
...
>     Couldn't we just put the label in the natural spot, like perl and
                               ^^^^^        ^^^^^^^^^^^^
>     Java, and disallow the label from being the target of both a
>     goto and a break/continue.

This is very frustrating; why does this idea appeal to so many people so
much that they think it is better that creating a new grammatical form for
a loop name?

Maybe some people like to call it a label, but it isn't what current C
standard would call a label - a label is a thing that is the target of a
goto.  I prefer to use the term "loop name".

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.

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, unless
a second grammatical form is used to introduced a "multi-reference" name
(say a double colon?).

- Martin.
Technical Details
Message-ID: <6495326.71820.1619@kcbbs.gen.nz>
Path: arc1-ca.pugleaf.net!auckland.ac.nz!kcbbs!martin
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>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!auckland.ac.nz!kcbbs!martin
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: Multi-level break and elimination of GOTO
From: martin@kcbbs.gen.nz (Martin Kealey)
Date: 23 Nov 95 19:57:00 GMT
Message-ID: <6495326.71820.1619@kcbbs.gen.nz>
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>
Organization: Kappa Crucis Unix BBS, Auckland, NZ.
Followup-To: comp.std.c,comp.lang.c
X-Newsreader: TIN [version 1.2 PL2]