From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_05,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,68321983359cf306,start X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Use of 'goto' Date: 1997/06/18 Message-ID: <01bc7c39$64813260$LocalHost@xhv46.dial.pipex.com>#1/1 X-Deja-AN: 249434064 Organization: UUNet UK server (post doesn't reflect views of UUNet UK) Keywords: goto; programming; Ada Newsgroups: comp.lang.ada Date: 1997-06-18T00:00:00+00:00 List-Id: Well, now to throw in my two pence worth [actually 3.704 pence, due to the effects of inflation]. One of the problems with discussing the use of 'goto' in practical situations, is that those practical situations tend to involve KSLoCs. Would you like me to post a multi-thousand liner to illustrate my point? I suspect not. So you will have to trust me. I once wrote a program (in Pascal actually) to emulate an old IBM data-entry machine on a PC. One of the data-entry machine's dubious features (one of many) was that it could be set to execute any one function ('dup' for example) repeatedly until the end of the disk was reached (8" disks - remember those?). Being naive then (don't laugh), I attempted to do it using structured constructs (for ..., while ..., repeat ..., etc.), and failed. Eventually, I had to give in and use (a couple of) gotos [reducing a horrible tangled mess to a really neat few dozen lines of code]. As an exercise (being a masochist), I decided to work out the equivalent with flags. Hundreds of flags later, and getting a real itch for a pizza, I gave up; but I think the point was proved. Theoretically, use of the goto can always be replaced by other things (this has been proved), but in practice - hah hah! Conclusion: a company which totally bans gotos is setting itself up for a fall. This is an extreme (and very rare) example. However, from years of (sometimes bitter) experience programming 'in the field' on real programs, I can put my hand on my heart and say that the humble goto comes in real handy every so often. It is sometimes by far the neatest way to do it; it is sometimes the only way to do it; it is sometimes the only way to replumb a piece of code in five minutes when you've only got five minutes (on the range, for example - boy could I tell some stories). It's never actually happened to me, interestingly, but if I were to join a project and someone were to say "don't use that goto", I would ask them why, knowing they could not answer. If they still insisted, I would quit, and that is rare thing for me to do. Code bigots come right down on the list of the things that crawl upon their belly. Ignorant code bigots come bottom. Is this a dangerous topic, or what? Nick ;-)