Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!feeder4.usenet.farm!feed.usenet.farm!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!85.12.16.69.MISMATCH!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx41.am4.POSTED!not-for-mail From: Spiros Bousbouras Newsgroups: comp.lang.c Subject: Re: An enhancement Message-ID: <4104@bongo-ra.co> References: <531a5bb6-dc81-4eeb-9adf-1bf8eb310f65@googlegroups.com> In-Reply-To: X-Organisation: Weyland-Yutani Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Lines: 43 X-Complaints-To: http://netreport.virginmedia.com NNTP-Posting-Date: Mon, 08 Oct 2018 23:16:55 UTC Organization: virginmedia.com Date: Mon, 08 Oct 2018 23:16:55 GMT X-Received-Bytes: 2209 X-Received-Body-CRC: 2194560400 Xref: csiph.com comp.lang.c:136447 On Tue, 9 Oct 2018 11:48:34 +1300 Ian Collins wrote: > On 09/10/18 11:44, David Kleinecke wrote: > > I want to propose an enhancement: > > > > Add to C the statement type > > DO identifier SEMICOLON > > where the identifier is a label. The meaning is that > > the statement just identified is replaced by the > > statement following the label. > > > > This enhancement is potentially ambiguous in > > DO identifier SEMICOLON WHILE ... SEMICOLON > > and this situation has come up in another thread > > and triggered my post here. In order to preserve > > conforming it is necessary that the ambiguity be > > resolved as a DO-WHILE leaving > > identifier SEMICOLON > > as the repeated code. But the whole reduces to > > WHILE .... SEMICOLON > > > > The purpose of this enhancement is to enable > > top-down coding in the sense Knuth wanted with > > his literate programming. You can write code > > like: > > int foo (int x) { > > if (x < 0) do trivial_case; > > else if (x == 0) do easy_case; > > else do usual_case; > > return; > > trivial_case: { > > .... } > > easy_case: { > > .... } > > usual_case: { > > .... }} > > which is generally easier to understand if you have > > given as labels good descriptive phrases. > > What's wrong with calling functions with good descriptive names? That was my thought too. Local functions which inherit the variables of the parent function seem to me more useful.