Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: I have a confession to make...
Date: Mon, 06 Sep 2021 06:30:20 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <86lf49vnkj.fsf@linuxsc.com>
References: <87y291v83n.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="3555d3b4345d8bc729243ac3d8ab4b79"; logging-data="1554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19P+nPTXmBgacesZ34/KyEjUBT1YlmyZGQ="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:19CJlaxG86A0dcDUMzbp23DiVfo= sha1:aMLXEalqj1xQPdZ+jcisQjU689Q=
Xref: csiph.com comp.lang.c:162645
Ben Bacarisse writes:
> [report of early bad experiences with GOTO.] It put me off for life.
>
> [...]
>
> That said, I've still never had to use one. I use the fact that I
> want one to prompt me to think if I've got the code wrong and, so
> far, I always decide I have.
I have a different approach. I learned early on to write code
without considering even the possibility of using goto. So when
I write code now (and for the last more than 40 years), 'goto'
just isn't in the vocabulary. Only after having written a full
implementation (of a function or perhaps set of functions), if
the code looks clunky for some reason do I go back (no pun
intended) and explore less orthodox alternatives, including the
possibility of using 'goto'. It does happen from time to time
that using 'goto' gives a better result along some axes in the
space of possible tradeoffs. How often? Rarely. Somewhere
between once a year and once per decade, if I had to guess. It's
always a judgment call as to which tradeoffs give the best result
overall.
Incidentally, I put 'switch', and to a lesser extent 'if', in
almost the same category as 'goto'. Unrestrained use of 'if'
or 'switch' is almost as bad as unrestrained use of 'goto'.