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 17653 invoked from network); 10 Mar 2023 16:56:10 -0000 Received: from minnie.tuhs.org (2600:3c01:e000:146::1) by inbox.vuxu.org with ESMTPUTF8; 10 Mar 2023 16:56:10 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 48C6B41569; Sat, 11 Mar 2023 02:56:06 +1000 (AEST) Received: from sdaoden.eu (sdaoden.eu [217.144.132.164]) by minnie.tuhs.org (Postfix) with ESMTPS id C46E54155E for ; Sat, 11 Mar 2023 02:55:55 +1000 (AEST) Date: Fri, 10 Mar 2023 17:55:52 +0100 Author: Steffen Nurpmeso From: Steffen Nurpmeso To: Dave Horsfall Message-ID: <20230310165552.czZmL%steffen@sdaoden.eu> In-Reply-To: References: <20230309230130.q4I-f%steffen@sdaoden.eu> Mail-Followup-To: Dave Horsfall , The Eunuchs Hysterical Society User-Agent: s-nail v14.9.24-432-g67dd7ec606 OpenPGP: id=EE19E1C1F2F7054F8D3954D8308964B51883A0DD; url=https://ftp.sdaoden.eu/steffen.asc; preference=signencrypt BlahBlahBlah: Any stupid boy can crush a beetle. But all the professors in the world can make no bugs. Message-ID-Hash: Q43JKMQKJVP57IHSJNIB66BUNUVQRUHZ X-Message-ID-Hash: Q43JKMQKJVP57IHSJNIB66BUNUVQRUHZ X-MailFrom: steffen@sdaoden.eu 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: The Eunuchs Hysterical Society 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: Dave Horsfall wrote in : |On Thu, 9 Mar 2023, Warner Losh wrote: |> In C I use it all the time to do goto err for common error recovery |> because C doesn't have anything better. | | |Me too :-) | | |Seriously, I also use setjmp()/longjmp() for a more elegant exit from a That is sheer unbelievable, really? _So_ expensive! |deeply-nested loop; "break N" to break out of "N" loops, anyone? I |haven't found that yet... Very often i find myself needing a restart necessity, so "continue N" would that be. Then again when "N" is a number instead of a label this is a (let alone maintainance) mess but for shortest code paths. All the "replacements", like closures, plain inner functions, even more contorted conditionals (i think in the last seven days i saw at least three fixes fly by due to logic errors in contorted conditionals, tiny C compiler, OpenBSD i think bpf/bgpd?, and some FreeBSD commit, which sums up as "Pascal: no"), and "state machine indicating variables" are not as elegant and cheap, and do not allow an as human-receivable control flow (imho), as a simple jump can be. Like my always quoted exampe that adds unnecessary conditionals which evaluate over and over again for nothing if(defined($nl = $self->begin_line)){ $self->begin_line(undef); $self->seen_endl(1); $ogoditisanewperl = 1 #goto jumpin; } while($ogoditisanewperl || ($nl = readline $self->infh)){ if(!$ogoditisanewperl){ ++${$self->__lineno}; $self->seen_endl($nl =~ s/(.*?)\s+$/$1/) } $ogoditisanewperl = 0; #jumpin: |Of course, in those days it was setexit() etc :-) ENTRY(setexit, 0) movab setsav,r0 movq r6,(r0)+ movq r8,(r0)+ movq r10,(r0)+ movq 8(fp),(r0)+ # ap, fp movab 4(ap),(r0)+ # sp movl 16(fp),(r0) # pc clrl r0 ret ENTRY(reset, 0) movl 4(ap),r0 # returned value movab setsav,r1 movq (r1)+,r6 movq (r1)+,r8 movq (r1)+,r10 movq (r1)+,r12 movl (r1)+,sp jmp *(r1) setsav: .space 10*4 .text Cheap it is not. But maybe cheaper than calling a closure or inner function with all the (repeated) stack setup and unwinding. |-- Dave --End of --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)