From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9439 invoked from network); 10 Mar 2023 15:46:11 -0000 Received: from minnie.tuhs.org (2600:3c01:e000:146::1) by inbox.vuxu.org with ESMTPUTF8; 10 Mar 2023 15:46:11 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 9888441546; Sat, 11 Mar 2023 01:46:07 +1000 (AEST) Received: from mcvoy.com (mcvoy.com [192.169.23.250]) by minnie.tuhs.org (Postfix) with ESMTPS id DFB5641536 for ; Sat, 11 Mar 2023 01:46:02 +1000 (AEST) Received: by mcvoy.com (Postfix, from userid 3546) id 8DCC635E1B7; Fri, 10 Mar 2023 07:46:02 -0800 (PST) Date: Fri, 10 Mar 2023 07:46:02 -0800 From: Larry McVoy To: Noel Chiappa Message-ID: <20230310154602.GX9225@mcvoy.com> References: <20230310153702.AFF3418C080@mercury.lcs.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230310153702.AFF3418C080@mercury.lcs.mit.edu> User-Agent: Mutt/1.5.24 (2015-08-30) Message-ID-Hash: QXLZMWXAHLFV7H2XS5OFVJNQ7USEPFPX X-Message-ID-Hash: QXLZMWXAHLFV7H2XS5OFVJNQ7USEPFPX X-MailFrom: lm@mcvoy.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: tuhs@tuhs.org X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: I can't drive 55: "GOTO considered harmful" 55th anniversary List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: I've used gotos for decades but in a "structured" way. My functions have a pattern: and there are a series of labels in the deallocation section. Then while you are wandering through the allocation section, you can jump to the right spot in the deallocation section. And yes, this is a simplification because I initialize all my pointers to NULL so the deallocation is all if (p) free(p); but the idea is the same. You wind up some state and wind down some state and the gotos are used to jump to the right place to unwind. On Fri, Mar 10, 2023 at 10:37:02AM -0500, Noel Chiappa wrote: > > From: "Ronald Natalie" > > > Multilevel breaks are as bad as goto with regard to structure violation. > > In a way, you are right. There isn't really much difference between: > > for (mumble) { > for (foobar) { > do some stuff > break-2; > } > } > > and: > > for (mumble) { > for (foobar) { > do some stuff > goto all_loops_done; > } > } > all_loops_done: > > > The former is basically just 'syntactic sugar' for the latter. > > I think the point is that goto's aren't necessarily _always_ bad, in and of > themselves; it's _how_, _where_ and _why_ one uses them. If one uses goto's > in a _structured_ way (oxymoronic as that sounds), to get around things that > are lacking in the language's flow-control, they're probably fine. > > Then, of course, one gets into the usual shrubbery of 'but suppose someone > uses them in a way that's _not_ structured?' There's no fixing stupid, is my > response. Nested 'if/then/else' can be used to write comletely > incomprehensible code (I have an amusing story about that) - but that's not > an argument against nested 'if/then/else'. > > As I've said before, the best sculpting tools in the world won't make a great > sculptor out of a ham-handed bozo. > > Noel -- --- Larry McVoy Retired to fishing http://www.mcvoy.com/lm/boat