comp.lang.ada
 help / color / mirror / Atom feed
* Use of 'goto'
@ 1997-06-18  0:00 Nick Roberts
  1997-06-20  0:00 ` Mike linnig
  1997-07-03  0:00 ` Shmuel (Seymour J.) Metz
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Roberts @ 1997-06-18  0:00 UTC (permalink / raw)




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 ;-)





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-07-03  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-18  0:00 Use of 'goto' Nick Roberts
1997-06-20  0:00 ` Mike linnig
1997-06-20  0:00   ` Robert Dewar
1997-07-03  0:00   ` Shmuel (Seymour J.) Metz
1997-07-03  0:00     ` Robert Dewar
1997-07-03  0:00 ` Shmuel (Seymour J.) Metz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox