🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3508

Re: Multi-level break and elimination of GOTO

#3508
From: Larry Wall
Date: Wed, 29 Nov 1995 00:41
85 lines
4488 bytes
In article <6495326.71820.1619@kcbbs.gen.nz>,
Martin Kealey <martin@kcbbs.gen.nz> wrote:
: 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?

Why does the idea of creating a new grammatical form appeal to you when
the old one works perfectly well?  Let me assure you, people will give
you just as much grief for inventing new grammatical forms.  :-)

: 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".

I don't really care how the current C standard defines it--they can
always redefine it.  I don't imagine comp.std.c was created merely to
maintain the status quo.  :-)

You label things, not the gaps between things.  You label the things to
give them a name, not a purpose.  This is Linguistics 101.

A label is simply a name for a statement, whether simple or compound.
In Perl, there is the tendency (encouraged by the design of the
language) to name a loop with the name of the item that you're
processing each time through, so that a statement like "next LINE"
makes sense both as English and as Perl.  The programmer doesn't
need to scan the code for the loop--it's just Around Here Somewhere.
And that is enough.  That's why we gave the loop a 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.

Then you're still thinking of the break as a goto, not as a natural
operation on a loop object with a meaningful name.  You need to break
out of that mindset.

: Perl & Java don't have to cope with the ambiguity of a goto label, so they
: are free to re-use the "label :" format.

Er, in Perl it's perfectly legal to use the same label for both
purposes.  There is no ambiguity, because the operation is determined
by the verb.  (Of course, I don't think I've ever actually used a goto
in a Perl program, except for testing.  But it's certainly there.)

: 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

Horrors.

: (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.

In practice, the keyword after the label gives you all the info you
need to begin with.  Especially if your language is not designed to
force you to use goto.  Eliminate the need for goto and you eliminate
the need to hedge goto about with paranoid restrictions.

: 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.

Sort of a turn-the-other-cheek notion, eh?

Larry Wall
lwall@sems.com
Technical Details
Message-ID: <1995Nov29.004130.8607@netlabs.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!netlabs!lwall
References: <486cj7$o4s@news.mel.aone.net.au> <490b59$3qt@panix.com> <491cb0$7dp@spool.cs.wisc.edu> <6495326.71820.1619@kcbbs.gen.nz>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c
Path: arc1-ca.pugleaf.net!in2.uu.net!netlabs!lwall
From: lwall@netlabs.com (Larry Wall)
Subject: Re: Multi-level break and elimination of GOTO
Message-ID: <1995Nov29.004130.8607@netlabs.com>
Organization: Seagate Enterprise Management Software, Cupertino, California.
References: <486cj7$o4s@news.mel.aone.net.au> <490b59$3qt@panix.com> <491cb0$7dp@spool.cs.wisc.edu> <6495326.71820.1619@kcbbs.gen.nz>
Date: Wed, 29 Nov 1995 00:41:30 GMT
X-Original-Newsgroups: comp.std.c,comp.lang.c