Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All your files have been destroyed (sorry). Paul.


devel / comp.lang.c / "GOTOphobia considered harmful (in C)" by Jorengarenar

SubjectAuthor
* "GOTOphobia considered harmful (in C)" by JorengarenarLynn McGuire
+* Re: "GOTOphobia considered harmful (in C)" by JorengarenarÖö Tiib
|`* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBen Bacarisse
| `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarÖö Tiib
|  `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBen Bacarisse
|   +* Re: "GOTOphobia considered harmful (in C)" by JorengarenarÖö Tiib
|   |`* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBen Bacarisse
|   | +* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|   | |`* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBen Bacarisse
|   | | `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarÖö Tiib
|   | |  +- Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|   | |  `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBen Bacarisse
|   | |   `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|   | |    `- Re: "GOTOphobia considered harmful (in C)" by JorengarenarBen Bacarisse
|   | `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarÖö Tiib
|   |  `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarDavid Brown
|   |   +* Re: "GOTOphobia considered harmful (in C)" by JorengarenarÖö Tiib
|   |   |`* Re: "GOTOphobia considered harmful (in C)" by Jorengarenardave thompson 2
|   |   | `- Re: "GOTOphobia considered harmful (in C)" by JorengarenarÖö Tiib
|   |   `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarScott Lurndal
|   |    `- Re: "GOTOphobia considered harmful (in C)" by JorengarenarDavid Brown
|   `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarTim Rentsch
|    `- Re: "GOTOphobia considered harmful (in C)" by Jorengarenarbart c
+* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|+* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBonita Montero
||`* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|| +* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBonita Montero
|| |`* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|| | `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarBonita Montero
|| |  `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarPo Lu
|| |   `- Re: "GOTOphobia considered harmful (in C)" by JorengarenarBonita Montero
|| `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarTim Rentsch
||  `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
||   `- Re: "GOTOphobia considered harmful (in C)" by JorengarenarTim Rentsch
|`* Re: "GOTOphobia considered harmful (in C)" by JorengarenarScott Lurndal
| `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|  `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarScott Lurndal
|   `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
|    +- Re: "GOTOphobia considered harmful (in C)" by JorengarenarDavid Brown
|    `* Re: "GOTOphobia considered harmful (in C)" by JorengarenarScott Lurndal
|     `- Re: "GOTOphobia considered harmful (in C)" by JorengarenarAnton Shepelev
+* Re: "GOTOphobia considered harmful (in C)" by JorengarenarTim Rentsch
|`- Re: "GOTOphobia considered harmful (in C)" by JorengarenarOpus
`- Re: "GOTOphobia considered harmful (in C)" by JorengarenarBonita Montero

Pages:12
"GOTOphobia considered harmful (in C)" by Jorengarenar

<ttoldr$2mou$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24846&group=comp.lang.c#24846

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lynnmcgu...@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c
Subject: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Wed, 1 Mar 2023 17:00:11 -0600
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ttoldr$2mou$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 1 Mar 2023 23:00:12 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="5757c35d9138820ce372df1c6725ea6d";
logging-data="88862"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yai3gVyIn0Jlk6LrMzo9StEJlrPTnsRs="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:L2QuzjLbv68zVwYXzWIGjFlQl9Y=
Content-Language: en-US
 by: Lynn McGuire - Wed, 1 Mar 2023 23:00 UTC

"GOTOphobia considered harmful (in C)" by Jorengarenar
https://blog.joren.ga/gotophobia-harmful

"gotophobia – fear of goto statement, usually caused by misunderstanding
and lack of context of stories from dark ages of programming.
Programmers with gotophobia tend to make their code less readable just
to avoid using goto."

"Everybody and their grandpa knows (the meme title of) Dijkstra's
Letters to the editor: go to statement considered harmful (submitted
under the title: A case against the goto statement), but most forget the
context of the 60s in which it was written, things we take for granted
were a novelty back then."

Lynn

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24849&group=comp.lang.c#24849

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:55e9:0:b0:56e:9f09:ee58 with SMTP id bu9-20020ad455e9000000b0056e9f09ee58mr2358425qvb.8.1677740600508;
Wed, 01 Mar 2023 23:03:20 -0800 (PST)
X-Received: by 2002:a5b:50:0:b0:ab8:1ed9:cfc5 with SMTP id e16-20020a5b0050000000b00ab81ed9cfc5mr4084062ybp.6.1677740600206;
Wed, 01 Mar 2023 23:03:20 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 1 Mar 2023 23:03:19 -0800 (PST)
In-Reply-To: <ttoldr$2mou$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=145.14.47.111; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 145.14.47.111
References: <ttoldr$2mou$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Thu, 02 Mar 2023 07:03:20 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2470
 by: Öö Tiib - Thu, 2 Mar 2023 07:03 UTC

On Thursday, 2 March 2023 at 01:00:26 UTC+2, Lynn McGuire wrote:
> "GOTOphobia considered harmful (in C)" by Jorengarenar
> https://blog.joren.ga/gotophobia-harmful
>
> "gotophobia – fear of goto statement, usually caused by misunderstanding
> and lack of context of stories from dark ages of programming.
> Programmers with gotophobia tend to make their code less readable just
> to avoid using goto."
>
> "Everybody and their grandpa knows (the meme title of) Dijkstra's
> Letters to the editor: go to statement considered harmful (submitted
> under the title: A case against the goto statement), but most forget the
> context of the 60s in which it was written, things we take for granted
> were a novelty back then."
>
A well used goto can sometimes help people to reason about code. Some
usages are idiomatic like cleanup and multi-level break/continue ... and
so should be taught to C students.

OTOH more loose branching can make compiler to statically analyse
it worse and so to warn incorrectly or to miss opportunity to optimise.

Tools help mainstream/average users the most. As programmers
use goto now more rarely the benchmarks and tests also contain
it less. So just avoiding it does not hurt, only avoiding at all costs
can be harmful.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24850&group=comp.lang.c#24850

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 11:40:33 +0300
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
References: <ttoldr$2mou$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="b5c2233e089cad6512522cb7ac00901f";
logging-data="282199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xsAHKf65UIIwuSPH3nkmpZmlWJE5dDok="
Cancel-Lock: sha1:ouIEijtS7szF2kAVcyLMAiU8Y3Y=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Thu, 2 Mar 2023 08:40 UTC

Lynn McGuire:

> "GOTOphobia considered harmful (in C)" by Jorengarenar
> https://blog.joren.ga/gotophobia-harmful
>
> "gotophobia -- fear of goto statement, usually caused by
> misunderstanding and lack of context of stories from dark
> ages of programming. Programmers with gotophobia tend to
> make their code less readable just to avoid using goto."

I entirely agree with this statement. In fact, I use some of
the patterns from that article in my C# code. See also my
similar comments to Ned Batchelder's great article about
exceptions:

https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<ttpo5b$8pgv$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24851&group=comp.lang.c#24851

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 09:54:22 +0100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ttpo5b$8pgv$2@dont-email.me>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Mar 2023 08:52:59 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b3c4f336778f88fc31ee620654256970";
logging-data="288287"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SqRcDx27yuPhTSgdwJ1SOu83Qw/dHIiQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:qVQ1784TVaJlnbyxHVHKp0zpkHk=
Content-Language: de-DE
In-Reply-To: <20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
 by: Bonita Montero - Thu, 2 Mar 2023 08:54 UTC

Am 02.03.2023 um 09:40 schrieb Anton Shepelev:

> -- () ascii ribbon campaign -- against html e-mail /\
> www.asciiribbon.org -- against proprietary attachments

With this website-design you'll gain no attention at all. ;-)

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24852&group=comp.lang.c#24852

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 12:38:04 +0300
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<ttpo5b$8pgv$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="b5c2233e089cad6512522cb7ac00901f";
logging-data="293210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rP7Na64uifZ+A9hkIQyhHgc330eRnJU8="
Cancel-Lock: sha1:TWxmwA+XMDKW6h0H53yYSFvxrBU=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Thu, 2 Mar 2023 09:38 UTC

Bonita Montero:
> Anton Shepelev:
>
> > > -- () ascii ribbon campaign -- against html e-mail /
> > > www.asciiribbon.org -- against proprietary attachments
>
> With this website-design you'll gain no attention at all.
> ;-)

Unlike the Responsive Design, which Google viciously
promotes by favouring it in its seaches and which is the
negation of itself, being slow, bloated, and irresponsive,
asciiribbon.org is a good wesbiste: clean, fast, HTML,
adapts to the width of the browser window, uses normal fonts
viewable without smoothing, and requires very little
resources.

Why did you mangle my signature?

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<ttpr32$92ek$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24853&group=comp.lang.c#24853

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 10:44:21 +0100
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ttpr32$92ek$1@dont-email.me>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<ttpo5b$8pgv$2@dont-email.me>
<20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Mar 2023 09:42:58 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b3c4f336778f88fc31ee620654256970";
logging-data="297428"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x6YGVfGnuIXBJLD5pe00p8PU3eG/ChA0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:F4ZpnJJz2BRWwl90UoGf/fSqZa4=
In-Reply-To: <20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>
Content-Language: de-DE
 by: Bonita Montero - Thu, 2 Mar 2023 09:44 UTC

Am 02.03.2023 um 10:38 schrieb Anton Shepelev:

> Unlike the Responsive Design, which Google viciously
> promotes by favouring it in its seaches and which is the
> negation of itself, being slow, bloated, and irresponsive,
> asciiribbon.org is a good wesbiste: clean, fast, HTML,
> adapts to the width of the browser window, uses normal fonts
> viewable without smoothing, and requires very little
> resources.

I've got a computer from 2017 with to 27" QHD-monitors
and a 50/25 line and don't have any convenience-issues
with any webpage.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<20230302131940.2efc431ce63ece5fdb8a1461@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24855&group=comp.lang.c#24855

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 13:19:40 +0300
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <20230302131940.2efc431ce63ece5fdb8a1461@g{oogle}mail.com>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<ttpo5b$8pgv$2@dont-email.me>
<20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>
<ttpr32$92ek$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="b5c2233e089cad6512522cb7ac00901f";
logging-data="302204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PnBuGweJIuNvH7GcM8vZpzd80EnWYwV4="
Cancel-Lock: sha1:KhktLz6fty05N0We29gs0/a1u3Q=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Thu, 2 Mar 2023 10:19 UTC

Bonita Montero:

> I've got a computer from 2017 with to 27" QHD-monitors and
> a 50/25 line and don't have any convenience-issues with
> any webpage.

I have a single 17-inch 5:4 display at work and a single
19-inch 4:3 one at home (which seems largish). The ergonomic
line length being about 70 characters, often I have to
shrink the browser window to make it narrower than my
display. Large (and especially widescreen) displays make me
stretch my neck. Also, I hate it if the pixels are two
small, so High-DPI is out of the question. My optimal raster
depth is about 90 ppi. Horisontally large displays spoil the
taste of the inexperienced, by encouraging long code lines.

If by "50/25 line" you refer to the standard text modes of
80x25 and 80x50 characters, then I sympathise with you,
although I can't imagine such a mode on so huge a display.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<87y1ofqo5h.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24858&group=comp.lang.c#24858

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 02 Mar 2023 13:27:22 +0000
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <87y1ofqo5h.fsf@bsb.me.uk>
References: <ttoldr$2mou$2@dont-email.me>
<97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="401121b04acf6ac107f3bfefb303f569";
logging-data="337995"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19EPVfu+rP+EEKR0OM6QVyD+BW4QIwXwDA="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:WiV8xTIW/6GiBqrDlF+L+Nkd2E4=
sha1:MHijdDxFr5PQQJ9WvUih9NP5ZKU=
X-BSB-Auth: 1.f9ee3c486b5bcbdb32ff.20230302132722GMT.87y1ofqo5h.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 2 Mar 2023 13:27 UTC

Öö Tiib <ootiib@hot.ee> writes:

> On Thursday, 2 March 2023 at 01:00:26 UTC+2, Lynn McGuire wrote:
>> "GOTOphobia considered harmful (in C)" by Jorengarenar
>> https://blog.joren.ga/gotophobia-harmful
>>
>> "gotophobia – fear of goto statement, usually caused by misunderstanding
>> and lack of context of stories from dark ages of programming.
>> Programmers with gotophobia tend to make their code less readable just
>> to avoid using goto."
>>
>> "Everybody and their grandpa knows (the meme title of) Dijkstra's
>> Letters to the editor: go to statement considered harmful (submitted
>> under the title: A case against the goto statement), but most forget the
>> context of the 60s in which it was written, things we take for granted
>> were a novelty back then."
>>
> A well used goto can sometimes help people to reason about code.

That's possible (since you say 'a' and that implies just one) but I've
not seen a case where what I call reasoning about code is easier with
any gotos.

It's common to think about gotos backwards -- that they solve a problem
at the point where one inserts one -- but the issue is that they create
problems at the point they jump to. To reason about code you need to
know the state of system at every point, and every jump to a label gives
another whole set of possible states that must be considered at the
target, and they are very unlikely to be closely related to the other
states one is already considering.

What usually goes by the term "a well used goto" is an attempt to
minimise this problem.

> Some
> usages are idiomatic like cleanup and multi-level break/continue ... and
> so should be taught to C students.

So that the copy that pattern in their own code or just so that they can
understand it when they see it? I think you mean the former as there is
not much to teach in the other case.

> OTOH more loose branching can make compiler to statically analyse
> it worse and so to warn incorrectly or to miss opportunity to optimise.
>
> Tools help mainstream/average users the most. As programmers
> use goto now more rarely the benchmarks and tests also contain
> it less. So just avoiding it does not hurt, only avoiding at all costs
> can be harmful.

Well that's one of those things that it true because of the phrasing --
nothing (in coding) should be avoided "at all costs"! The question is
what is the cost of avoiding gotos? In my experience it is usually a
benefit and not a cost at all.

--
Ben.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<W73ML.1391192$9sn9.582493@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24860&group=comp.lang.c#24860

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Newsgroups: comp.lang.c
References: <ttoldr$2mou$2@dont-email.me> <20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
Lines: 20
Message-ID: <W73ML.1391192$9sn9.582493@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 02 Mar 2023 15:19:18 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 02 Mar 2023 15:19:18 GMT
X-Received-Bytes: 1480
 by: Scott Lurndal - Thu, 2 Mar 2023 15:19 UTC

Anton Shepelev <anton.txt@g{oogle}mail.com> writes:
>Lynn McGuire:
>
>> "GOTOphobia considered harmful (in C)" by Jorengarenar
>> https://blog.joren.ga/gotophobia-harmful
>>
>> "gotophobia -- fear of goto statement, usually caused by
>> misunderstanding and lack of context of stories from dark
>> ages of programming. Programmers with gotophobia tend to
>> make their code less readable just to avoid using goto."
>
>I entirely agree with this statement. In fact, I use some of
>the patterns from that article in my C# code. See also my
>similar comments to Ned Batchelder's great article about
>exceptions:
>
> https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239

A fair amount of nonsense, cherry picking egregious examples of
one method and slighting the egregious examples of the other.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<20230302184934.7531bd2de2fd9deba923c680@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24861&group=comp.lang.c#24861

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 18:49:34 +0300
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <20230302184934.7531bd2de2fd9deba923c680@g{oogle}mail.com>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<W73ML.1391192$9sn9.582493@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="b5c2233e089cad6512522cb7ac00901f";
logging-data="363440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dRRHfiwfsxWmhN3KEHaTLCqFgaVopHTM="
Cancel-Lock: sha1:jP5YxokHp+bsITpFO1zeZfb1IvA=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Thu, 2 Mar 2023 15:49 UTC

Scott Lurndal to Anton Shepelev:

> > https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239
>
> A fair amount of nonsense, cherry picking egregious
> examples of one method and slighting the egregious
> examples of the other.

That is your opinion. Where are your arguments? Which
examples do you think I cherry-picked and which I slighted?
Slighing implies unjustified rebuke, whereas I provided
arguments.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<hT3ML.168202$0dpc.78369@fx33.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24862&group=comp.lang.c#24862

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx33.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Newsgroups: comp.lang.c
References: <ttoldr$2mou$2@dont-email.me> <20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com> <W73ML.1391192$9sn9.582493@fx17.iad> <20230302184934.7531bd2de2fd9deba923c680@g{oogle}mail.com>
Lines: 33
Message-ID: <hT3ML.168202$0dpc.78369@fx33.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 02 Mar 2023 16:09:49 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 02 Mar 2023 16:09:49 GMT
X-Received-Bytes: 2250
 by: Scott Lurndal - Thu, 2 Mar 2023 16:09 UTC

Anton Shepelev <anton.txt@g{oogle}mail.com> writes:
>Scott Lurndal to Anton Shepelev:
>
>> > https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239
>>
>> A fair amount of nonsense, cherry picking egregious
>> examples of one method and slighting the egregious
>> examples of the other.
>
>That is your opinion. Where are your arguments? Which
>examples do you think I cherry-picked and which I slighted?
>Slighing implies unjustified rebuke, whereas I provided
>arguments.

Personally, I find both exceptions and status returns useful,
favoring the later because it is generally much easier to
attempt to recover from an issue closer to the issue. For example,
the 'open' system call returns a status code and the calling function
has all the appropriate information (file name, reason for failure)
to deal with the issue immediately, rather than defering to some
exception handler somewhere which may not have the context necessary
to handle the issue intelligently.

IME, most programmers who use exceptions simply terminate the application; the
applications (operating systems, hypervisors, large-scale simulation
tools) require more than simply crashing on exception.

Then there is inevitable run-time overhead cost to maintain the
ability to unwind the stack when handling exceptions, which in
at least one case (a CPU simulator) where I attempted to replace 'siglongjmp' with
standard C++ exceptions caused a 20% performance drop in the
application.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<20230302194111.733f995a6f5b65c77b1d2929@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24863&group=comp.lang.c#24863

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 19:41:11 +0300
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <20230302194111.733f995a6f5b65c77b1d2929@g{oogle}mail.com>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<W73ML.1391192$9sn9.582493@fx17.iad>
<20230302184934.7531bd2de2fd9deba923c680@g{oogle}mail.com>
<hT3ML.168202$0dpc.78369@fx33.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="b5c2233e089cad6512522cb7ac00901f";
logging-data="373060"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dLvzcQOob51n9MJe4zIp3R+BHn+5sBZY="
Cancel-Lock: sha1:6+9fbb7d8A4oXsRkBPG9a4NbejY=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Thu, 2 Mar 2023 16:41 UTC

Scott Lurndal to Anton Shepelev:

> > Scott Lurndal to Anton Shepelev:
> >
> > > > https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239
> > >
> > > A fair amount of nonsense, cherry picking egregious
> > > examples of one method and slighting the egregious
> > > examples of the other.
> >
> > That is your opinion. Where are your arguments? Which
> > examples do you think I cherry-picked and which I
> > slighted? Slighing implies unjustified rebuke, whereas
> > I provided arguments.
>
> Personally, I find both exceptions and status returns
> useful, favoring the later because it is generally much
> easier to attempt to recover from an issue closer to the
> issue. For example, the 'open' system call returns a
> status code and the calling function has all the
> appropriate information (file name, reason for failure) to
> deal with the issue immediately, rather than defering to
> some exception handler somewhere which may not have the
> context necessary to handle the issue intelligently.

I agree. Did you get a different impression from my
comments above? Or, perhaps, you referred to Ned
Batchelder's blog post rather than to my comments?

> IME, most programmers who use exceptions simply terminate
> the application; the applications (operating systems,
> hypervisors, large-scale simulation tools) require more
> than simply crashing on exception.

In my experience, this is childish and stupid. Where I am
forced to use exceptions, I certainly use them in more
complex ways, including gathering information though several
stack levels, deinitialisation (e.g. transaction rollbakc),
and error recovery (e.g. reconnection and repeated DB
requests after deadlocks).

> Then there is inevitable run-time overhead cost to
> maintain the ability to unwind the stack when handling
> exceptions, which in at least one case (a CPU simulator)
> where I attempted to replace 'siglongjmp' with standard
> C++ exceptions caused a 20% performance drop in the
> application.

I thought the were implementations where the happy path
incurred zero overhead.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<ttqk47$bd57$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24864&group=comp.lang.c#24864

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 17:50:15 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <ttqk47$bd57$1@dont-email.me>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<W73ML.1391192$9sn9.582493@fx17.iad>
<20230302184934.7531bd2de2fd9deba923c680@g{oogle}mail.com>
<hT3ML.168202$0dpc.78369@fx33.iad>
<20230302194111.733f995a6f5b65c77b1d2929@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Mar 2023 16:50:15 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="5fa3502b9eb7f33adf2d189a2cadc899";
logging-data="373927"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+wHWZvOmqSuzfeakrj0bJOKkdOyPDqDY="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.4.2
Cancel-Lock: sha1:yR5Kdy8i1J+zl85W+zbdcABDHu8=
In-Reply-To: <20230302194111.733f995a6f5b65c77b1d2929@g{oogle}mail.com>
Content-Language: en-GB
 by: David Brown - Thu, 2 Mar 2023 16:50 UTC

On 02/03/2023 17:41, Anton Shepelev wrote:
> Scott Lurndal to Anton Shepelev:

>> Then there is inevitable run-time overhead cost to
>> maintain the ability to unwind the stack when handling
>> exceptions, which in at least one case (a CPU simulator)
>> where I attempted to replace 'siglongjmp' with standard
>> C++ exceptions caused a 20% performance drop in the
>> application.
>
> I thought the were implementations where the happy path
> incurred zero overhead.
>

The /aim/ is low overhead, but the practice is not always zero overhead.
(I suspect 20% performance overhead is quite unusual, however.)
Compilers are inevitably going to be more restricted when they are
required to be able to unwind the stack - it can limit reordering (since
throwing an exception becomes observable behaviour), or perhaps force
objects to be created on the stack in their entirety, whereas with
exceptions disabled the compiler might be able to put some or all of an
object in registers.

It is probably fair to say that exceptions are often more efficient (for
the non-exception path) compared to alternatives that do a similar
amount of work, but for some applications they are not close enough to
zero overhead to be suitable.

(In small systems embedded programming, it is standard practice to
compile with "-fno-exceptions".)

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<ttqlil$bjvp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24865&group=comp.lang.c#24865

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 18:16:24 +0100
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ttqlil$bjvp$1@dont-email.me>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<ttpo5b$8pgv$2@dont-email.me>
<20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>
<ttpr32$92ek$1@dont-email.me>
<20230302131940.2efc431ce63ece5fdb8a1461@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Mar 2023 17:15:01 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b3c4f336778f88fc31ee620654256970";
logging-data="380921"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+j9ONIW8CrAjCPmo0xsUiqS0W4EE2gHCQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:qSUf56njiSExEmpV/ir1VqwUzUk=
In-Reply-To: <20230302131940.2efc431ce63ece5fdb8a1461@g{oogle}mail.com>
Content-Language: de-DE
 by: Bonita Montero - Thu, 2 Mar 2023 17:16 UTC

Am 02.03.2023 um 11:19 schrieb Anton Shepelev:

> I have a single 17-inch 5:4 display at work and a
> single 19-inch 4:3 one at home (which seems largish). ...

Use proper hardware.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<9t5ML.1633625$vBI8.138003@fx15.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24867&group=comp.lang.c#24867

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Newsgroups: comp.lang.c
References: <ttoldr$2mou$2@dont-email.me> <20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com> <W73ML.1391192$9sn9.582493@fx17.iad> <20230302184934.7531bd2de2fd9deba923c680@g{oogle}mail.com> <hT3ML.168202$0dpc.78369@fx33.iad> <20230302194111.733f995a6f5b65c77b1d2929@g{oogle}mail.com>
Lines: 67
Message-ID: <9t5ML.1633625$vBI8.138003@fx15.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 02 Mar 2023 17:58:29 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 02 Mar 2023 17:58:29 GMT
X-Received-Bytes: 3583
 by: Scott Lurndal - Thu, 2 Mar 2023 17:58 UTC

Anton Shepelev <anton.txt@g{oogle}mail.com> writes:
>Scott Lurndal to Anton Shepelev:
>
>> > Scott Lurndal to Anton Shepelev:
>> >
>> > > > https://nedbatchelder.com/text/exceptions-vs-status.html#comment_15239
>> > >
>> > > A fair amount of nonsense, cherry picking egregious
>> > > examples of one method and slighting the egregious
>> > > examples of the other.
>> >
>> > That is your opinion. Where are your arguments? Which
>> > examples do you think I cherry-picked and which I
>> > slighted? Slighing implies unjustified rebuke, whereas
>> > I provided arguments.
>>
>> Personally, I find both exceptions and status returns
>> useful, favoring the later because it is generally much
>> easier to attempt to recover from an issue closer to the
>> issue. For example, the 'open' system call returns a
>> status code and the calling function has all the
>> appropriate information (file name, reason for failure) to
>> deal with the issue immediately, rather than defering to
>> some exception handler somewhere which may not have the
>> context necessary to handle the issue intelligently.
>
>I agree. Did you get a different impression from my
>comments above? Or, perhaps, you referred to Ned
>Batchelder's blog post rather than to my comments?

My apologies. The comment was directed at the blog post,
not your comments.

>
>> IME, most programmers who use exceptions simply terminate
>> the application; the applications (operating systems,
>> hypervisors, large-scale simulation tools) require more
>> than simply crashing on exception.
>
>In my experience, this is childish and stupid.

I don't disagree.

>Where I am
>forced to use exceptions, I certainly use them in more
>complex ways, including gathering information though several
>stack levels, deinitialisation (e.g. transaction rollbakc),
>and error recovery (e.g. reconnection and repeated DB
>requests after deadlocks).
>
>> Then there is inevitable run-time overhead cost to
>> maintain the ability to unwind the stack when handling
>> exceptions, which in at least one case (a CPU simulator)
>> where I attempted to replace 'siglongjmp' with standard
>> C++ exceptions caused a 20% performance drop in the
>> application.
>
>I thought the were implementations where the happy path
>incurred zero overhead.

I haven't seen that with gcc generated code, where there
are added calls to the crt code to handle stack unwinding
in functions even if the exception isn't thrown.

In the case above, it was a simple replacement of siglongjmp
with 'throw' that cost 20% in the execution speed of the
simulated processor.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24868&group=comp.lang.c#24868

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:5651:b0:56e:a203:5d1f with SMTP id mh17-20020a056214565100b0056ea2035d1fmr2848132qvb.5.1677782421115;
Thu, 02 Mar 2023 10:40:21 -0800 (PST)
X-Received: by 2002:a5b:b03:0:b0:ace:1ae4:9dd2 with SMTP id
z3-20020a5b0b03000000b00ace1ae49dd2mr2724852ybp.8.1677782420811; Thu, 02 Mar
2023 10:40:20 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 2 Mar 2023 10:40:20 -0800 (PST)
In-Reply-To: <87y1ofqo5h.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=145.14.47.111; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 145.14.47.111
References: <ttoldr$2mou$2@dont-email.me> <97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
<87y1ofqo5h.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Thu, 02 Mar 2023 18:40:21 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Öö Tiib - Thu, 2 Mar 2023 18:40 UTC

On Thursday, 2 March 2023 at 15:27:38 UTC+2, Ben Bacarisse wrote:
> Öö Tiib <oot...@hot.ee> writes:
>
> > On Thursday, 2 March 2023 at 01:00:26 UTC+2, Lynn McGuire wrote:
> >> "GOTOphobia considered harmful (in C)" by Jorengarenar
> >> https://blog.joren.ga/gotophobia-harmful
> >>
> >> "gotophobia – fear of goto statement, usually caused by misunderstanding
> >> and lack of context of stories from dark ages of programming.
> >> Programmers with gotophobia tend to make their code less readable just
> >> to avoid using goto."
> >>
> >> "Everybody and their grandpa knows (the meme title of) Dijkstra's
> >> Letters to the editor: go to statement considered harmful (submitted
> >> under the title: A case against the goto statement), but most forget the
> >> context of the 60s in which it was written, things we take for granted
> >> were a novelty back then."
> >>
> > A well used goto can sometimes help people to reason about code.
> That's possible (since you say 'a' and that implies just one) but I've
> not seen a case where what I call reasoning about code is easier with
> any gotos.
>
Strange ... as in next sentence I brought three cases that are quite
idiomatic. Quantity is one or few as it is good idea to keep functions short.
> It's common to think about gotos backwards -- that they solve a problem
> at the point where one inserts one -- but the issue is that they create
> problems at the point they jump to. To reason about code you need to
> know the state of system at every point, and every jump to a label gives
> another whole set of possible states that must be considered at the
> target, and they are very unlikely to be closely related to the other
> states one is already considering.
>
> What usually goes by the term "a well used goto" is an attempt to
> minimise this problem.
>
I don't know what people think. I use goto where it makes my
intention more clear with well named label and also shortens the
code by reducing conditionals or removing duplicates.

> > Some
> > usages are idiomatic like cleanup and multi-level break/continue ... and
> > so should be taught to C students.
>
> So that the copy that pattern in their own code or just so that they can
> understand it when they see it? I think you mean the former as there is
> not much to teach in the other case.
>
Like with all idiomatic usages it is just how to handle certain situations.

> > OTOH more loose branching can make compiler to statically analyse
> > it worse and so to warn incorrectly or to miss opportunity to optimise.
> >
> > Tools help mainstream/average users the most. As programmers
> > use goto now more rarely the benchmarks and tests also contain
> > it less. So just avoiding it does not hurt, only avoiding at all costs
> > can be harmful.
>
> Well that's one of those things that it true because of the phrasing --
> nothing (in coding) should be avoided "at all costs"! The question is
> what is the cost of avoiding gotos? In my experience it is usually a
> benefit and not a cost at all.
>
Great. I however have seen plenty of misuses of other language
constructs for to get something done without goto. For example
do { /*code*/ } while(0); loop just to be able to use breaks as gotos
in that /*code*/.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<87mt4urk13.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24869&group=comp.lang.c#24869

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 02 Mar 2023 20:11:04 +0000
Organization: A noiseless patient Spider
Lines: 103
Message-ID: <87mt4urk13.fsf@bsb.me.uk>
References: <ttoldr$2mou$2@dont-email.me>
<97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
<87y1ofqo5h.fsf@bsb.me.uk>
<6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="401121b04acf6ac107f3bfefb303f569";
logging-data="407530"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EVmegWT8qZ3iYz9ZmeqvNe0u+C7Tql40="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:bDExE9WH8ayKgK2aYCfj7766o8k=
sha1:WweTslLSxPMd92UpmecBH/YrMBc=
X-BSB-Auth: 1.cb9b94c6631a8a3d4f24.20230302201104GMT.87mt4urk13.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 2 Mar 2023 20:11 UTC

Öö Tiib <ootiib@hot.ee> writes:

> On Thursday, 2 March 2023 at 15:27:38 UTC+2, Ben Bacarisse wrote:
>> Öö Tiib <oot...@hot.ee> writes:
>>
>> > On Thursday, 2 March 2023 at 01:00:26 UTC+2, Lynn McGuire wrote:
>> >> "GOTOphobia considered harmful (in C)" by Jorengarenar
>> >> https://blog.joren.ga/gotophobia-harmful
>> >>
>> >> "gotophobia – fear of goto statement, usually caused by misunderstanding
>> >> and lack of context of stories from dark ages of programming.
>> >> Programmers with gotophobia tend to make their code less readable just
>> >> to avoid using goto."
>> >>
>> >> "Everybody and their grandpa knows (the meme title of) Dijkstra's
>> >> Letters to the editor: go to statement considered harmful (submitted
>> >> under the title: A case against the goto statement), but most forget the
>> >> context of the 60s in which it was written, things we take for granted
>> >> were a novelty back then."
>> >>
>> > A well used goto can sometimes help people to reason about code.
>> That's possible (since you say 'a' and that implies just one) but I've
>> not seen a case where what I call reasoning about code is easier with
>> any gotos.
>>
> Strange ... as in next sentence I brought three cases that are quite
> idiomatic. Quantity is one or few as it is good idea to keep functions
> short.

I'm not sure what you think is strange.

>> It's common to think about gotos backwards -- that they solve a problem
>> at the point where one inserts one -- but the issue is that they create
>> problems at the point they jump to. To reason about code you need to
>> know the state of system at every point, and every jump to a label gives
>> another whole set of possible states that must be considered at the
>> target, and they are very unlikely to be closely related to the other
>> states one is already considering.
>>
>> What usually goes by the term "a well used goto" is an attempt to
>> minimise this problem.
>>
> I don't know what people think.

One advantage of teaching programming is that it's really helpful to ask
what your students are thinking. It helps to see where they are coming
from. Of course they may not e typical, but it gives an insight that is
often missing from other environments.

> I use goto where it makes my
> intention more clear with well named label and also shortens the
> code by reducing conditionals or removing duplicates.

I think everyone (nowadays) uses goto when it makes the intention clear.
But you raised the issue of reasoning about code (something I am very
keen on) so I made an observation about that, one that is often
overlooked: the purpose of the goto may be clear, but it complicates the
reasoning at the target.

>> > Some
>> > usages are idiomatic like cleanup and multi-level break/continue ... and
>> > so should be taught to C students.
>>
>> So that the copy that pattern in their own code or just so that they can
>> understand it when they see it? I think you mean the former as there is
>> not much to teach in the other case.
>>
> Like with all idiomatic usages it is just how to handle certain
> situations.

"It is just how to handle certain situations" does not address my
question. I know it /is/ done, but /should/ it be done? Should we
teach it just so that it's understood, or so that everyone keeps doing
it?

>> > OTOH more loose branching can make compiler to statically analyse
>> > it worse and so to warn incorrectly or to miss opportunity to optimise.
>> >
>> > Tools help mainstream/average users the most. As programmers
>> > use goto now more rarely the benchmarks and tests also contain
>> > it less. So just avoiding it does not hurt, only avoiding at all costs
>> > can be harmful.
>>
>> Well that's one of those things that it true because of the phrasing --
>> nothing (in coding) should be avoided "at all costs"! The question is
>> what is the cost of avoiding gotos? In my experience it is usually a
>> benefit and not a cost at all.
>>
> Great. I however have seen plenty of misuses of other language
> constructs for to get something done without goto. For example
> do { /*code*/ } while(0); loop just to be able to use breaks as gotos
> in that /*code*/.

breaks /are/ gotos[1] -- there's no avoiding that fact -- so they also
complicate the reasoning at the target. Writing convoluted code just to
disguise a goto as a break is bonkers, but it's more enlightening to
discuss best practice rather than worst!

[1] in C I don't count break in switch statements. There, it's /not/
writing a break that complicates things!

--
Ben.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<20230302231328.e15abe9bb2c70d9a9370024d@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24870&group=comp.lang.c#24870

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Thu, 2 Mar 2023 23:13:28 +0300
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20230302231328.e15abe9bb2c70d9a9370024d@gmail.moc>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<W73ML.1391192$9sn9.582493@fx17.iad>
<20230302184934.7531bd2de2fd9deba923c680@g{oogle}mail.com>
<hT3ML.168202$0dpc.78369@fx33.iad>
<20230302194111.733f995a6f5b65c77b1d2929@g{oogle}mail.com>
<9t5ML.1633625$vBI8.138003@fx15.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="a310d9224ab07acf15804c5af95eb51a";
logging-data="412868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187l8degtiaA9ZykdYBqCKvI1ZQbBI3k/U="
Cancel-Lock: sha1:r+X98RDrwuUKVr727dicv7JQppU=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Thu, 2 Mar 2023 20:13 UTC

Scott Lurndal to Anton Shepelev:

> > Scott Lurndal:
> >
> > > IME, most programmers who use exceptions simply
> > > terminate the application; the applications (operating
> > > systems, hypervisors, large-scale simulation tools)
> > > require more than simply crashing on exception.
> >
> > In my experience, this is childish and stupid.
>
> I don't disagree.

To explain -- throwing raw exceptions at the user rarely
helps him understand what went wrong, and where.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<s3m4jr22jww.fsf@yahoo.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24881&group=comp.lang.c#24881

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: luang...@yahoo.com (Po Lu)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Fri, 03 Mar 2023 18:45:03 +0800
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <s3m4jr22jww.fsf@yahoo.com>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<ttpo5b$8pgv$2@dont-email.me>
<20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>
<ttpr32$92ek$1@dont-email.me>
<20230302131940.2efc431ce63ece5fdb8a1461@g{oogle}mail.com>
<ttqlil$bjvp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="1db3aaee85b1c9b1c5d56fbb70c15fcf";
logging-data="661260"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+701xIPduv0KAmKu5D03xz2Z6mxkAA8SQ="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:D47v3oDKdN0eDL15cTyk9PjoQyw=
sha1:jCejk8jCkBjWPXq5zGl1iodVsIk=
 by: Po Lu - Fri, 3 Mar 2023 10:45 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:

> Am 02.03.2023 um 11:19 schrieb Anton Shepelev:
>
>> I have a single 17-inch 5:4 display at work and a
>> single 19-inch 4:3 one at home (which seems largish). ...
>
> Use proper hardware.

Most people do not share your definition of "proper".
Not everyone lives in a theater.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<b3ddff3d-e58a-4a36-bc42-5e3410eb97e3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24882&group=comp.lang.c#24882

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:4146:0:b0:3bf:ff6d:ad8b with SMTP id e6-20020ac84146000000b003bfff6dad8bmr421244qtm.9.1677841435294;
Fri, 03 Mar 2023 03:03:55 -0800 (PST)
X-Received: by 2002:a5b:108:0:b0:8bb:dfe8:a33b with SMTP id
8-20020a5b0108000000b008bbdfe8a33bmr700989ybx.9.1677841435111; Fri, 03 Mar
2023 03:03:55 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 3 Mar 2023 03:03:54 -0800 (PST)
In-Reply-To: <87mt4urk13.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=84.50.190.130; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 84.50.190.130
References: <ttoldr$2mou$2@dont-email.me> <97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
<87y1ofqo5h.fsf@bsb.me.uk> <6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>
<87mt4urk13.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b3ddff3d-e58a-4a36-bc42-5e3410eb97e3n@googlegroups.com>
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Fri, 03 Mar 2023 11:03:55 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Öö Tiib - Fri, 3 Mar 2023 11:03 UTC

On Thursday, 2 March 2023 at 22:11:22 UTC+2, Ben Bacarisse wrote:
> Öö Tiib <oot...@hot.ee> writes:
>
> > On Thursday, 2 March 2023 at 15:27:38 UTC+2, Ben Bacarisse wrote:
> >> Öö Tiib <oot...@hot.ee> writes:
> >>
> >> >>
> >> > A well used goto can sometimes help people to reason about code.
> >> That's possible (since you say 'a' and that implies just one) but I've
> >> not seen a case where what I call reasoning about code is easier with
> >> any gotos.
> >>
> > Strange ... as in next sentence I brought three cases that are quite
> > idiomatic. Quantity is one or few as it is good idea to keep functions
> > short.
> I'm not sure what you think is strange.
>
I think it strange that you have never seen those idiomatic usages. I've
not seen better alternatives to some of those in C.

> > I use goto where it makes my
> > intention more clear with well named label and also shortens the
> > code by reducing conditionals or removing duplicates.
>
> I think everyone (nowadays) uses goto when it makes the intention clear.
> But you raised the issue of reasoning about code (something I am very
> keen on) so I made an observation about that, one that is often
> overlooked: the purpose of the goto may be clear, but it complicates the
> reasoning at the target.

It indeed can complicate reasoning for novice who is unfamiliar with
some idiom. Even MISRA C took less dogmatic stance towards goto about
ten years ago IIRC. So under some circumstances it is not that simple
to avoid.

Other programming languages have added language elements for those
circumstances like ... guard, defer, throw, repeat, scope, labeled break,
closures, coroutines, continuations and so on.
But more is often not better as we have experienced. Each of those
needs to be taught. Area of potential usage is dim, can overlap with other
element, performance costs can differ. So it is no way simpler to teach nor
to learn.

> >> > Some
> >> > usages are idiomatic like cleanup and multi-level break/continue ... and
> >> > so should be taught to C students.
> >>
> >> So that the copy that pattern in their own code or just so that they can
> >> understand it when they see it? I think you mean the former as there is
> >> not much to teach in the other case.
> >>
> > Like with all idiomatic usages it is just how to handle certain
> > situations.
>
> "It is just how to handle certain situations" does not address my
> question. I know it /is/ done, but /should/ it be done? Should we
> teach it just so that it's understood, or so that everyone keeps doing
> it?

My bad. I think both should be done. The problems where for example
multi-level break or continue are handy are typically interesting on their
own. Or the other example of proper handling of stopping, canceling or
retrying where multiple different resources may need to be released
(but language does not have exceptions or RAII) is useful skill.

> >> Well that's one of those things that it true because of the phrasing --
> >> nothing (in coding) should be avoided "at all costs"! The question is
> >> what is the cost of avoiding gotos? In my experience it is usually a
> >> benefit and not a cost at all.
> >>
> > Great. I however have seen plenty of misuses of other language
> > constructs for to get something done without goto. For example
> > do { /*code*/ } while(0); loop just to be able to use breaks as gotos
> > in that /*code*/.
>
> breaks /are/ gotos[1] -- there's no avoiding that fact -- so they also
> complicate the reasoning at the target. Writing convoluted code just to
> disguise a goto as a break is bonkers, but it's more enlightening to
> discuss best practice rather than worst!
>
"Those are gotos" can be said about early returns and exceptions
as well. But saying so presumes that goto is a bad thing.
I do not see it as bad thing ... just bit too generic. About like pointer
is bit too generic. There are no much else to do but to break the
loop when it is discovered that loop does not need to continue
looping (or even may not do so for safely) . So if there are no
break (nor early returns or exceptions) then we have goto.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<87h6v1rh1a.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24885&group=comp.lang.c#24885

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Fri, 03 Mar 2023 15:28:01 +0000
Organization: A noiseless patient Spider
Lines: 145
Message-ID: <87h6v1rh1a.fsf@bsb.me.uk>
References: <ttoldr$2mou$2@dont-email.me>
<97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
<87y1ofqo5h.fsf@bsb.me.uk>
<6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>
<87mt4urk13.fsf@bsb.me.uk>
<b3ddff3d-e58a-4a36-bc42-5e3410eb97e3n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader01.eternal-september.org; posting-host="9664380c7f8b659d25b84839c1563171";
logging-data="716472"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/ykrbIMlmSvUImo+X/cqHEFfkW0XVZIw="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:IDrpJoUe/DUn8nfq2eFXUAgPASk=
sha1:mOLRuPSBEqwn5crrx/C9pPVics4=
X-BSB-Auth: 1.89e0143f0179c0640975.20230303152801GMT.87h6v1rh1a.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 3 Mar 2023 15:28 UTC

Öö Tiib <ootiib@hot.ee> writes:

> On Thursday, 2 March 2023 at 22:11:22 UTC+2, Ben Bacarisse wrote:
>> Öö Tiib <oot...@hot.ee> writes:
>>
>> > On Thursday, 2 March 2023 at 15:27:38 UTC+2, Ben Bacarisse wrote:
>> >> Öö Tiib <oot...@hot.ee> writes:
>> >>
>> >> >>
>> >> > A well used goto can sometimes help people to reason about code.
>> >> That's possible (since you say 'a' and that implies just one) but I've
>> >> not seen a case where what I call reasoning about code is easier with
>> >> any gotos.
>> >>
>> > Strange ... as in next sentence I brought three cases that are quite
>> > idiomatic. Quantity is one or few as it is good idea to keep functions
>> > short.
>> I'm not sure what you think is strange.
>>
> I think it strange that you have never seen those idiomatic usages.

I don't know how you came to that conclusion. I've been using C for over
30 years, so of course I am aware of them. I even remember a time
before they had not yet become idiomatic!

What I was saying is that I've not seen an example that makes reasoning
about the code easier. I've seen cases where I don't think the goto
makes reasoning any harder, but not one where it actually helps to
reason about the code.

> I've
> not seen better alternatives to some of those in C.

That's the trouble when something becomes idiomatic -- the alternatives
become rare.

>> > I use goto where it makes my
>> > intention more clear with well named label and also shortens the
>> > code by reducing conditionals or removing duplicates.
>>
>> I think everyone (nowadays) uses goto when it makes the intention clear.
>> But you raised the issue of reasoning about code (something I am very
>> keen on) so I made an observation about that, one that is often
>> overlooked: the purpose of the goto may be clear, but it complicates the
>> reasoning at the target.
>
> It indeed can complicate reasoning for novice who is unfamiliar with
> some idiom.

You think I am a novice (or at least think like one) when it comes to
reasoning about code?

> Even MISRA C took less dogmatic stance towards goto about
> ten years ago IIRC. So under some circumstances it is not that simple
> to avoid.
>
> Other programming languages have added language elements for those
> circumstances like ... guard, defer, throw, repeat, scope, labeled break,
> closures, coroutines, continuations and so on.
> But more is often not better as we have experienced. Each of those
> needs to be taught. Area of potential usage is dim, can overlap with other
> element, performance costs can differ. So it is no way simpler to teach nor
> to learn.

I don't think we can get into that huge family of constructs. Let's
stick to talking about what C has.

>> >> > Some
>> >> > usages are idiomatic like cleanup and multi-level break/continue ... and
>> >> > so should be taught to C students.
>> >>
>> >> So that the copy that pattern in their own code or just so that they can
>> >> understand it when they see it? I think you mean the former as there is
>> >> not much to teach in the other case.
>> >>
>> > Like with all idiomatic usages it is just how to handle certain
>> > situations.
>>
>> "It is just how to handle certain situations" does not address my
>> question. I know it /is/ done, but /should/ it be done? Should we
>> teach it just so that it's understood, or so that everyone keeps doing
>> it?
>
> My bad. I think both should be done.

OK, thanks. I disagree, and I am happy to say more if you think it
might be useful in some way.

> The problems where for example
> multi-level break or continue are handy are typically interesting on their
> own. Or the other example of proper handling of stopping, canceling or
> retrying where multiple different resources may need to be released
> (but language does not have exceptions or RAII) is useful skill.

Yes, it is useful to know how to handle these cases. I rarely think
that goto is the best option, though I am not entirely opposed to their
use.

>> >> Well that's one of those things that it true because of the phrasing --
>> >> nothing (in coding) should be avoided "at all costs"! The question is
>> >> what is the cost of avoiding gotos? In my experience it is usually a
>> >> benefit and not a cost at all.
>> >>
>> > Great. I however have seen plenty of misuses of other language
>> > constructs for to get something done without goto. For example
>> > do { /*code*/ } while(0); loop just to be able to use breaks as gotos
>> > in that /*code*/.
>>
>> breaks /are/ gotos[1] -- there's no avoiding that fact -- so they also
>> complicate the reasoning at the target. Writing convoluted code just to
>> disguise a goto as a break is bonkers, but it's more enlightening to
>> discuss best practice rather than worst!
>>
> "Those are gotos" can be said about early returns and exceptions
> as well.

Such a case could be made for early returns, I agree. While some are
just an if with an implied else, others can indeed do more damage to the
reasoning.

C does not have exceptions (thank gooness!) which are a whole other can
of worms.

> But saying so presumes that goto is a bad thing.

I don't saying that they are gotos presumes that gotos are bad. break
and continue can also complicate the reasoning at the target, but I am
not an absolutist about the matter.

Also, I don't want to get into an argument about classification. If you
don't think of them as gotos with an implicit label, then that's fine.
Let's leave them to one side.

> I do not see it as bad thing ... just bit too generic. About like pointer
> is bit too generic. There are no much else to do but to break the
> loop when it is discovered that loop does not need to continue
> looping (or even may not do so for safely) . So if there are no
> break (nor early returns or exceptions) then we have goto.

That's an interesting turn of phrase. I think the style of programming
where one "discovers" that a loop needs to be stopped might be more of a
problem that the coding style that results from it.

--
Ben.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<20230303194427.0ed8587447a7a557ee6dc12e@g{oogle}mail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24886&group=comp.lang.c#24886

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: anton....@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Fri, 3 Mar 2023 19:44:27 +0300
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <20230303194427.0ed8587447a7a557ee6dc12e@g{oogle}mail.com>
References: <ttoldr$2mou$2@dont-email.me>
<97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
<87y1ofqo5h.fsf@bsb.me.uk>
<6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>
<87mt4urk13.fsf@bsb.me.uk>
<b3ddff3d-e58a-4a36-bc42-5e3410eb97e3n@googlegroups.com>
<87h6v1rh1a.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="d78d98703c93f53d41921af0b55b6903";
logging-data="731572"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Vqlsf9MJ7vMacWRFmB+fxvULzuXqlGw8="
Cancel-Lock: sha1:OCiCq6w6K0IjMhoJR4YP3+UQIuU=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Fri, 3 Mar 2023 16:44 UTC

Ben Bacarisse:

> I've seen cases where I don't think the goto makes
> reasoning any harder, but not one where it actually helps
> to reason about the code.

Nested `if' statements express control flow as a binary
tree, but very frequently control flow is, pardon me, a
unary tree, or a stack:

INIT 1
INIT 2
INIT 3
....
CLEAN 3
CLEAN 2
CLEAN 1

It is linear in the sense that it is expressible as a
sequence of INIT-DEINIT pairs:

INIT 1 -- DEINIT 1
INIT 2 -- DEINIT 2
INIT 3 -- DEINIT 3

Expressing it with nested `if' statements is therefore
redundant, and this redundancy causes it to be perceived as
ugly, cumbersome, and unreadable:

IF INIT 1
IF INIT 2
IF INIT 3
DEINIT 3
DEINIT 2
DEINIT 1

so that adding another INIT-DEINIT pair requires another
nesting level, which I think is both structurally and
aesthetically poor, because elegant code grows vertically
rather than horisontally. `goto' statements can express
this control flow in a more structural manner:

IF NOT INIT 1 THEN GOTO E_1
IF NOT INIT 2 THEN GOTO E_2
IF NOT INIT 3 THEN GOTO E_3

DEINIT 3
E_3: DEINIT 2
E_2: DEINIT 1
E_1: NOP

Compared to structured control flow, `goto' seem indeed to
help reason about this code, and at least they do not thwart
reasoning as strongly.

How do you code linear sequences of operations where the
only non-linearity is due to the need to handle errors
and/or release resources?

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<tttar6$mit7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24887&group=comp.lang.c#24887

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Fri, 3 Mar 2023 18:31:38 +0100
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <tttar6$mit7$1@dont-email.me>
References: <ttoldr$2mou$2@dont-email.me>
<20230302114033.654382f460982f9c7d3446c9@g{oogle}mail.com>
<ttpo5b$8pgv$2@dont-email.me>
<20230302123804.6f77aa4c2d3002f6ddbd4ec6@g{oogle}mail.com>
<ttpr32$92ek$1@dont-email.me>
<20230302131940.2efc431ce63ece5fdb8a1461@g{oogle}mail.com>
<ttqlil$bjvp$1@dont-email.me> <s3m4jr22jww.fsf@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 3 Mar 2023 17:30:14 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="bc6e3059cc914711e140fec7369aac69";
logging-data="740263"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19pep0nnXIsUB0sFztNCpFj06T/9fB50SE="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:J0IfU2oca7BhBMbBIdWBPNl5yEs=
Content-Language: de-DE
In-Reply-To: <s3m4jr22jww.fsf@yahoo.com>
 by: Bonita Montero - Fri, 3 Mar 2023 17:31 UTC

Am 03.03.2023 um 11:45 schrieb Po Lu:

> Bonita Montero <Bonita.Montero@gmail.com> writes:

>> Am 02.03.2023 um 11:19 schrieb Anton Shepelev:

>>> I have a single 17-inch 5:4 display at work and a
>>> single 19-inch 4:3 one at home (which seems largish). ...

>> Use proper hardware.

> Most people do not share your definition of "proper".
> ...

Most people would agree that the above hardware mentionend by Anton
isn't proper hardware.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<9c077df3-72e3-41cf-ab99-d8c9295607b5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24888&group=comp.lang.c#24888

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:58d:0:b0:71f:b89c:4f2f with SMTP id 135-20020a37058d000000b0071fb89c4f2fmr661170qkf.9.1677865783550;
Fri, 03 Mar 2023 09:49:43 -0800 (PST)
X-Received: by 2002:a25:9082:0:b0:855:fa17:4f66 with SMTP id
t2-20020a259082000000b00855fa174f66mr1488391ybl.8.1677865783377; Fri, 03 Mar
2023 09:49:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 3 Mar 2023 09:49:43 -0800 (PST)
In-Reply-To: <87h6v1rh1a.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=84.50.190.130; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 84.50.190.130
References: <ttoldr$2mou$2@dont-email.me> <97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
<87y1ofqo5h.fsf@bsb.me.uk> <6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>
<87mt4urk13.fsf@bsb.me.uk> <b3ddff3d-e58a-4a36-bc42-5e3410eb97e3n@googlegroups.com>
<87h6v1rh1a.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9c077df3-72e3-41cf-ab99-d8c9295607b5n@googlegroups.com>
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Fri, 03 Mar 2023 17:49:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 9189
 by: Öö Tiib - Fri, 3 Mar 2023 17:49 UTC

On Friday, 3 March 2023 at 17:28:17 UTC+2, Ben Bacarisse wrote:
> Öö Tiib <oot...@hot.ee> writes:
>
> > On Thursday, 2 March 2023 at 22:11:22 UTC+2, Ben Bacarisse wrote:
> >> Öö Tiib <oot...@hot.ee> writes:
> >>
> >> > On Thursday, 2 March 2023 at 15:27:38 UTC+2, Ben Bacarisse wrote:
> >> >> Öö Tiib <oot...@hot.ee> writes:
> >> >>
> >> >> >>
> >> >> > A well used goto can sometimes help people to reason about code.
> >> >> That's possible (since you say 'a' and that implies just one) but I've
> >> >> not seen a case where what I call reasoning about code is easier with
> >> >> any gotos.
> >> >>
> >> > Strange ... as in next sentence I brought three cases that are quite
> >> > idiomatic. Quantity is one or few as it is good idea to keep functions
> >> > short.
> >> I'm not sure what you think is strange.
> >>
> > I think it strange that you have never seen those idiomatic usages.
>
> I don't know how you came to that conclusion. I've been using C for over
> 30 years, so of course I am aware of them. I even remember a time
> before they had not yet become idiomatic!
>
> What I was saying is that I've not seen an example that makes reasoning
> about the code easier. I've seen cases where I don't think the goto
> makes reasoning any harder, but not one where it actually helps to
> reason about the code.
>
OK maybe it is about "easy". I meant that when I see familiar patterns then
those make it easier for me to understand and reason about the situation.
With every feature it can be both ways, where it is expected and fits to
pattern where it seems odd. If it seems odd then on closer inspection
there is often some logic error, some missing check, inefficiency, resource
leak or unneeded repetition. Odd usage of goto can stand out as can lack
of it.
>
> > I've
> > not seen better alternatives to some of those in C.
> That's the trouble when something becomes idiomatic -- the alternatives
> become rare.
> >> > I use goto where it makes my
> >> > intention more clear with well named label and also shortens the
> >> > code by reducing conditionals or removing duplicates.
> >>
> >> I think everyone (nowadays) uses goto when it makes the intention clear.
> >> But you raised the issue of reasoning about code (something I am very
> >> keen on) so I made an observation about that, one that is often
> >> overlooked: the purpose of the goto may be clear, but it complicates the
> >> reasoning at the target.
> >
> > It indeed can complicate reasoning for novice who is unfamiliar with
> > some idiom.
>
> You think I am a novice (or at least think like one) when it comes to
> reasoning about code?
>
No. Like I said ... I know that I don't know how other people think. So I am
just proposing what can complicate reasoning. About 35 years ago someone
who some years later became main architect of software in a bank told me
that he hates for loops ... that for him it is easier to reason about ifs and
gotos. I was as puzzled as I'm now.

> >> >> > Some
> >> >> > usages are idiomatic like cleanup and multi-level break/continue .... and
> >> >> > so should be taught to C students.
> >> >>
> >> >> So that the copy that pattern in their own code or just so that they can
> >> >> understand it when they see it? I think you mean the former as there is
> >> >> not much to teach in the other case.
> >> >>
> >> > Like with all idiomatic usages it is just how to handle certain
> >> > situations.
> >>
> >> "It is just how to handle certain situations" does not address my
> >> question. I know it /is/ done, but /should/ it be done? Should we
> >> teach it just so that it's understood, or so that everyone keeps doing
> >> it?
> >
> > My bad. I think both should be done.
>
> OK, thanks. I disagree, and I am happy to say more if you think it
> might be useful in some way.
>
Yes it can be useful in some way.

> > The problems where for example
> > multi-level break or continue are handy are typically interesting on their
> > own. Or the other example of proper handling of stopping, canceling or
> > retrying where multiple different resources may need to be released
> > (but language does not have exceptions or RAII) is useful skill.
>
> Yes, it is useful to know how to handle these cases. I rarely think
> that goto is the best option, though I am not entirely opposed to their
> use.
>
I do not mean that goto is very commonly needed. For example nested
loops themselves do not scale and so should be avoided where possible.

> >> >> Well that's one of those things that it true because of the phrasing --
> >> >> nothing (in coding) should be avoided "at all costs"! The question is
> >> >> what is the cost of avoiding gotos? In my experience it is usually a
> >> >> benefit and not a cost at all.
> >> >>
> >> > Great. I however have seen plenty of misuses of other language
> >> > constructs for to get something done without goto. For example
> >> > do { /*code*/ } while(0); loop just to be able to use breaks as gotos
> >> > in that /*code*/.
> >>
> >> breaks /are/ gotos[1] -- there's no avoiding that fact -- so they also
> >> complicate the reasoning at the target. Writing convoluted code just to
> >> disguise a goto as a break is bonkers, but it's more enlightening to
> >> discuss best practice rather than worst!
> >>
> > "Those are gotos" can be said about early returns and exceptions
> > as well.
> Such a case could be made for early returns, I agree. While some are
> just an if with an implied else, others can indeed do more damage to the
> reasoning.
>
> C does not have exceptions (thank gooness!) which are a whole other can
> of worms.
>
Yes, exceptions without RAII (like in Java) can make it quite inconvenient
to manage important resources. As C has to manage all resources explicitly
it would be even more inconvenient feature.

> > But saying so presumes that goto is a bad thing.
> I don't saying that they are gotos presumes that gotos are bad. break
> and continue can also complicate the reasoning at the target, but I am
> not an absolutist about the matter.
>
> Also, I don't want to get into an argument about classification. If you
> don't think of them as gotos with an implicit label, then that's fine.
> Let's leave them to one side.
>
OK

> > I do not see it as bad thing ... just bit too generic. About like pointer
> > is bit too generic. There are no much else to do but to break the
> > loop when it is discovered that loop does not need to continue
> > looping (or even may not do so for safely) . So if there are no
> > break (nor early returns or exceptions) then we have goto.
>
> That's an interesting turn of phrase. I think the style of programming
> where one "discovers" that a loop needs to be stopped might be more of a
> problem that the coding style that results from it.
>
Mature software code base is usually such. About 80% of code lines
deal with various corner/edge cases and situations. Situation is
often impossible or expensive to predict before being in it. And then
it needs to deal with it cancel or undo what was done clean up and
forward the information about issue up stack.

Re: "GOTOphobia considered harmful (in C)" by Jorengarenar

<87ttz1wmoo.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24889&group=comp.lang.c#24889

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: "GOTOphobia considered harmful (in C)" by Jorengarenar
Date: Fri, 03 Mar 2023 21:27:03 +0000
Organization: A noiseless patient Spider
Lines: 120
Message-ID: <87ttz1wmoo.fsf@bsb.me.uk>
References: <ttoldr$2mou$2@dont-email.me>
<97967f5a-d810-49e6-9c30-68b66bce9f7dn@googlegroups.com>
<87y1ofqo5h.fsf@bsb.me.uk>
<6f13ff47-fbe3-4c41-9df6-ce9752e73e85n@googlegroups.com>
<87mt4urk13.fsf@bsb.me.uk>
<b3ddff3d-e58a-4a36-bc42-5e3410eb97e3n@googlegroups.com>
<87h6v1rh1a.fsf@bsb.me.uk>
<20230303194427.0ed8587447a7a557ee6dc12e@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="9664380c7f8b659d25b84839c1563171";
logging-data="785305"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+KEwMf2KFqM6zjOVSZLyjCDQ+A2aUXuQ="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:RRm5HbwwSj6ogNwgbWitUeWSoJ4=
sha1:kEukbsWqlMxD1gVYHiIOXW8FPW0=
X-BSB-Auth: 1.a2a596cdb39d523fb8ba.20230303212703GMT.87ttz1wmoo.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 3 Mar 2023 21:27 UTC

Anton Shepelev <anton.txt@g{oogle}mail.com> writes:

> Ben Bacarisse:
>
>> I've seen cases where I don't think the goto makes
>> reasoning any harder, but not one where it actually helps
>> to reason about the code.
>
> Nested `if' statements express control flow as a binary
> tree, but very frequently control flow is, pardon me, a
> unary tree, or a stack:
>
> INIT 1
> INIT 2
> INIT 3
> ....
> CLEAN 3
> CLEAN 2
> CLEAN 1
>
> It is linear in the sense that it is expressible as a
> sequence of INIT-DEINIT pairs:
>
> INIT 1 -- DEINIT 1
> INIT 2 -- DEINIT 2
> INIT 3 -- DEINIT 3
>
> Expressing it with nested `if' statements is therefore
> redundant, and this redundancy causes it to be perceived as
> ugly, cumbersome, and unreadable:

I don't perceive it that way. The nested blocks represent, both
visually and logically, the nested "stack" of actions.

But the perception is not really the point. I was talking about
reasoning about the code. I know how to reason about ifs, so when I
see:

FILE *in = fopen("input", "r");
if (in) {
FILE *out = fopen("output), "w");
if (out) {
char *buffer = malloc(1000);
if (buffer) {
// off we go!
free(buffer);
}
fclose(out);
}
fclose(in);
}

I know the fcloses are never performed on null file pointers (and if it
were more idiomatic in C, I'd put consts in there to have the compiler
check that 'in' and 'out' are not changed).

> IF INIT 1
> IF INIT 2
> IF INIT 3
> DEINIT 3
> DEINIT 2
> DEINIT 1
>
> so that adding another INIT-DEINIT pair requires another
> nesting level, which I think is both structurally and
> aesthetically poor, because elegant code grows vertically
> rather than horisontally.

You can make a case for the aesthetics (though I would probably
disagree) but it's not structurally poor to use the simplest and best
known structured programming construct.

But your adding another level brings up a very important point. When
you find that adding more nested constructs gets ugly, it's time to
think about a helper function. C is not the best assistant in this
regard (I have to write a top-level function and I can't easily return
multiple values) but I would still choose that option.

> `goto' statements can express
> this control flow in a more structural manner:
>
> IF NOT INIT 1 THEN GOTO E_1
> IF NOT INIT 2 THEN GOTO E_2
> IF NOT INIT 3 THEN GOTO E_3
>
> DEINIT 3
> E_3: DEINIT 2
> E_2: DEINIT 1
> E_1: NOP

This is simply not what I call structured. I think you object to
nesting even when it shows how the code is actually nested. The
structured version shows the structure!

When the actions involved are more complex than the text "INIT n" and
"DEINIT n" even the simply visual pattern matching starts to go wrong
with the goto version. Maybe you stick with numbers, but most people
don't and I have to check the label and goto ordering. And because this
pattern includes not extra blocks, my logical conditions (we are talking
about reasoning) has to include more variables.

> Compared to structured control flow, `goto' seem indeed to
> help reason about this code, and at least they do not thwart
> reasoning as strongly.

How does it help the reasoning? As far as I can see, I have more things
to check and more state to be aware of at every label.

> How do you code linear sequences of operations where the
> only non-linearity is due to the need to handle errors
> and/or release resources?

I use ifs and helper functions.

I understand that there is a lot of personal taste involved in the
broader topic, but when it comes to just the formal reasoning, I think
there is much less subjectivity.

--
Ben.

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor