From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: Dave Horsfall <dave@horsfall.org>
Cc: The Eunuchs Hysterical Society <tuhs@tuhs.org>
Subject: [TUHS] Re: I can't drive 55: "GOTO considered harmful" 55th anniversary
Date: Fri, 10 Mar 2023 17:55:52 +0100 [thread overview]
Message-ID: <20230310165552.czZmL%steffen@sdaoden.eu> (raw)
In-Reply-To: <alpine.BSF.2.21.9999.2303101657460.4881@aneurin.horsfall.org>
Dave Horsfall wrote in
<alpine.BSF.2.21.9999.2303101657460.4881@aneurin.horsfall.org>:
|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.
|
|<AOL>
|Me too :-)
|</AOL>
|
|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 <alpine.BSF.2.21.9999.2303101657460.4881@aneurin.horsfall.org>
--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)
next prev parent reply other threads:[~2023-03-10 16:56 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 23:01 [TUHS] " Steffen Nurpmeso
2023-03-09 23:18 ` [TUHS] " segaloco via TUHS
2023-03-09 23:21 ` Warner Losh
2023-03-09 23:31 ` Luther Johnson
2023-03-09 23:44 ` josh
2023-03-09 23:54 ` Warner Losh
2023-03-10 0:54 ` segaloco via TUHS
2023-03-10 1:08 ` Warner Losh
2023-03-10 10:08 ` Ralph Corderoy
2023-03-10 11:37 ` arnold
2023-03-10 11:56 ` Ralph Corderoy
2023-03-10 11:59 ` arnold
2023-03-10 12:11 ` Ralph Corderoy
2023-03-10 6:15 ` Dave Horsfall
2023-03-10 16:55 ` Steffen Nurpmeso [this message]
2023-03-10 17:02 ` Bakul Shah
2023-03-12 20:47 ` Dave Horsfall
2023-03-12 21:50 ` Warner Losh
2023-03-12 22:27 ` Steffen Nurpmeso
2023-03-13 3:09 ` [TUHS] Re: I can't drive 55: "GOTO considered harmful" 55thanniversary Dave Horsfall
2023-03-14 19:54 ` Steffen Nurpmeso
2023-03-10 1:31 ` [TUHS] Re: I can't drive 55: "GOTO considered harmful" 55th anniversary Rich Morin
2023-03-10 11:37 Noel Chiappa
2023-03-10 15:54 ` Dan Cross
2023-03-12 7:39 ` Anthony Martin
2023-03-12 11:40 ` Dan Cross
2023-03-12 16:40 ` Paul Winalski
2023-03-13 3:25 ` John Cowan
2023-03-13 10:40 ` Alejandro Colomar (man-pages)
2023-03-13 12:19 ` Dan Cross
2023-03-10 11:51 Noel Chiappa
2023-03-10 14:16 ` Ronald Natalie
2023-03-10 14:39 ` John Cowan
2023-03-10 16:30 ` Phil Budne
2023-03-10 17:50 ` Steffen Nurpmeso
2023-03-10 17:57 ` Paul Winalski
2023-03-10 18:12 ` Lawrence Stewart
2023-03-10 17:28 ` Clem Cole
2023-03-10 17:54 ` Paul Winalski
2023-03-10 15:37 Noel Chiappa
2023-03-10 15:46 ` Larry McVoy
2023-03-10 16:04 ` Dan Cross
2023-03-10 18:55 ` Ron Natalie
2023-03-10 19:04 ` Dan Cross
2023-03-10 19:35 ` segaloco via TUHS
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230310165552.czZmL%steffen@sdaoden.eu \
--to=steffen@sdaoden.eu \
--cc=dave@horsfall.org \
--cc=tuhs@tuhs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).