🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3497

Re: Multi-level break and elimination of GOTO

#3497
From: Luke Kendall,M,805-2982
Date: Fri, 17 Nov 1995 03:17
43 lines
1953 bytes
comeau@panix.com (Greg Comeau) wrote:

> Or to minimize impacts to the grammar, why not just leave as normal 
labels:
>
>     outer: for(...) { ... }
>
> but that doesn't fly as well, so how about:
>
>     for(...) { ... } outer:

Here's my suggestion.  I believe it's minimalist, easy to implement,
and semantically clear.  :-)

Use labels to label the statement as you would presently.  So:

outer:	for (i =  0; i < 10; ++i)
	{
	}

and so on.  Extend the syntax and the semantics of both the `break'
and `continue' statements, to allow an optional label following.

	break outer;
	continue outer;

The semantics simply mean `break out of the loop or switch identified
by the given label' (and `continue the loop identified by the given
label').  Which I would suggest is a semantically clean way of
thinking about what you're doing.

I don't think any of this is an argument for trying to eliminate
the goto.  Seriously, like so much of C, the construct is there
for use when necessary.  It only causes problems when used when
it shouldn't be.

C is a language designed with a respect for the programmer; it
doesn't assume that they're children or vandals.  It assumes
they know what they're doing.  And the language has been kept
small enough so that a deep understanding is not too hard to
achieve.

luke
Technical Details
Message-ID: <DI63tn.9F1@research.canon.oz.au>
Path: arc1-ca.pugleaf.net!mama.research.canon.oz.au!news
References: <43pdut$hoh@galaxy.csc.calpoly.edu> <DF8FE3.97H@news.cern.ch> <47s7l0$r18@news.mel.aone.net.au> <480ps3$nqj@panix.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c,comp.lang.c
Path: arc1-ca.pugleaf.net!mama.research.canon.oz.au!news
From: luke@tosh.research.canon.com.au (Luke Kendall,M,805-2982)
Subject: Re: Multi-level break and elimination of GOTO
X-Nntp-Posting-Host: tosh.research.canon.com.au
Message-ID: <DI63tn.9F1@research.canon.oz.au>
Sender: news@research.canon.oz.au
Organization: Canon Information Systems Research Australia
X-Newsreader: Alexandra.app (Version 0.8b)
References: <43pdut$hoh@galaxy.csc.calpoly.edu> <DF8FE3.97H@news.cern.ch> <47s7l0$r18@news.mel.aone.net.au> <480ps3$nqj@panix.com>
Date: Fri, 17 Nov 1995 03:17:47 GMT