🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3477

Re: Multi-level break and elimination of GOTO

#3477
From: Richard Krehbiel
Date: Mon, 13 Nov 1995 13:09
53 lines
2657 bytes
comeau@panix.com (Greg Comeau) wrote:

>In article <DHpCK1.HyG@kroete2.freinet.de> ehcorry@inet.uni-c.dk (Erik Corry) writes:
>>: Andrew Dunbar (andrewd@agnus.livewire.com.au) wrote:
>>: : for outer (x = 0; x < MAXX; x++)
>>: :     ...
>>: :          break (outer);
>>
>>What I think is wrong with 'named loops':
>>
>>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!

>Assuming this proposal could ever actually gain momentum, I wouldn't
>be for the ()'s on the break, but would never reject it for parsing 
>problems.  In fact, I think the parsing would be ok  and not the problem
>you mention.

I think I'd disallow the parentheses in "break" and "continue".
"goto" doesn't allow them.

>The real problem I have with this proposal is that it only considers `for'
>(and probably `while').  If to be stronger, it could be more general than
>just those, plus consider appropriateness of special cases.

I would include "switch"...

switch label (value) stmt
for label ([expr1]; [expr2]; [expr3]) stmt
while label (expr1) stmt
do stmt while label (expr1);

If you like, require a colon following the label, but as it wouldn't
be a valid target for goto, I don't think it should look that much
like one.

As far as a more general proposal, has there been any sort of proposal
for a scope-restricted goto label?  Totally off the cuff, suppose that
if a label is surrounded by parens, then the scope of the label is
limited to the current block.

>Even with that though, no doubt we still wouldn't see it fly...

This is my expectation.  There will probably be no such changes as
these in the new standard.

--
Richard Krehbiel, Kastle Systems, Arlington VA USA
rich@kastle.com (work) or richk@cais.com (personal)
Technical Details
Message-ID: <1995Nov13.130427.11548@friend.kastle.com>
Path: arc1-ca.pugleaf.net!uu4news.netcom.com!friend!news
References: <DF8FE3.97H@news.cern.ch> <rnbohuqj8p3.fsf@euax7i3c01.eua.ericsson.se> <DHpCK1.HyG@kroete2.freinet.de> <480oqa$l1j@panix.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c
Path: arc1-ca.pugleaf.net!uu4news.netcom.com!friend!news
From: rich@kastle.com (Richard Krehbiel)
Subject: Re: Multi-level break and elimination of GOTO
Message-ID: <1995Nov13.130427.11548@friend.kastle.com>
Sender: news@friend.kastle.com (News)
Reply-To: rich@kastle.com
Organization: Kastle Development Associates
X-Newsreader: Forte Free Agent 1.0.82
References: <DF8FE3.97H@news.cern.ch> <rnbohuqj8p3.fsf@euax7i3c01.eua.ericsson.se> <DHpCK1.HyG@kroete2.freinet.de> <480oqa$l1j@panix.com>
Date: Mon, 13 Nov 1995 13:09:44 GMT