Sujet : Re: Fixing a sample from K&R book using cake static analyser
De : anton.txt (at) *nospam* gmail.moc (Anton Shepelev)
Groupes : comp.lang.cDate : 23. Jun 2024, 23:33:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240624013337.36fdb40f0766c6e1c8ce67c7@gmail.moc>
References : 1 2 3 4
User-Agent : Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Ben Bacarisse to Anton Shelelev:
Why are you so afraid of `goto' that you must emulate it
with `while' and `break'?
>
Why are you so fond of them that you add three extra state
variables that have to be (mentally and/or mathematically
tracked) just understand this supposedly simply function?
Because my attempts to fix the function without the extra
variables proved even worse.
This, to me, is a textbook case of why goto is harmful. I
have spend considerable time jumping up and down checking
the state of all the variables and I am still not sure I
follow what this supposedly simple function is doing.
I have tried to keep the structure simple: all the goto's
jump down, both the labels define isolated blocks, guared by
returns, to prevent fall-though.
(And everyone seems keen on redundant casts. Why?)
As I said, I could not test the function without extra work,
so I tried to change as little as possible.
-- () ascii ribbon campaign -- against html e-mail/\ www.asciiribbon.org -- against proprietary attachments