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

* Re: Use of 'goto'
  1997-06-20  0:00 ` Mike linnig
@ 1997-06-20  0:00   ` Robert Dewar
  1997-07-03  0:00   ` Shmuel (Seymour J.) Metz
  1 sibling, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1997-06-20  0:00 UTC (permalink / raw)



Mike says

<<Having said all that, our standards still restrict GOTO's, but we put in an
escape clause that says that the team lead can override the standards if
it is required.>>

Perfectly appropriate. Actually there are very few rules which should NOT
be able to be overridden with some kind of appropriate controls.





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

* Re: Use of 'goto'
  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 ` Shmuel (Seymour J.) Metz
  1 sibling, 2 replies; 6+ messages in thread
From: Mike linnig @ 1997-06-20  0:00 UTC (permalink / raw)



In article <01bc7c39$64813260$LocalHost@xhv46.dial.pipex.com>, "Nick
Roberts" <Nick.Roberts@dial.pipex.com> wrote:

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

Well after having been involved in a rewrite of our Ada coding standards
I've come to the conclusion that people concentrate on things that are
easy to detect.   It is  easy to detect the use of goto, it is quite
visible, you can grep for it.   

Spagetti code is bad, spagetti code uses gotos, therefore goto is bad.  
Lots of things are bad in Ada.  Global variables run amok is bad.  
Confusing variable name are bad.   It is not always possible to define
what is bad in a way that a non-programmer observer can detect it (SQE's,
the boss).

I think training is a better way to make good code than arbitrary restrictions
on easy to notice features.    In most environments, peer pressure will cause
folks to move away from bad constructs if everyone has similar ideas on
what is bad.

Having said all that, our standards still restrict GOTO's, but we put in an
escape clause that says that the team lead can override the standards if
it is required.   This raises the visibilty to the person responsible for
getting the job done and 'teaches' the programmer that goto's are a construct
that should not be used lightly.

Regards,

   Mike Linnig


+-----------------------------------------+
| Mike Linnig                             |
| Phone: (972) 927-3469                   |
+-----------------------------------------+




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

* Re: Use of 'goto'
  1997-07-03  0:00   ` Shmuel (Seymour J.) Metz
@ 1997-07-03  0:00     ` Robert Dewar
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Dewar @ 1997-07-03  0:00 UTC (permalink / raw)



Seymour J said

<<A false conclusion from a false premise, even if you allow use of "pons
asinorum" (B, A=>B, therefore A). Spaghetti code need not use GOTO, and
some of the worst examples I've seen did not.
>>


Well you perhaps have some definition of spaghetti. it is not exactly
a technical term. But certainly in most languages you cannot create
irreducible control structures without using a goto.





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

* Re: Use of 'goto'
  1997-06-18  0:00 Use of 'goto' Nick Roberts
  1997-06-20  0:00 ` Mike linnig
@ 1997-07-03  0:00 ` Shmuel (Seymour J.) Metz
  1 sibling, 0 replies; 6+ messages in thread
From: Shmuel (Seymour J.) Metz @ 1997-07-03  0:00 UTC (permalink / raw)



Nick Roberts wrote:
> 
>  Theoretically, use of the goto can always be replaced
> by other things (this has been proved), but in practice - hah hah!

Actually, that's not true. You're thinking of the article by Bohm (sp?)
and Jacopini, but what they proved was subtly different and not as
strong.

> 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 it was me, you'd be wrong. I've told that to students, but only when
I saw a cleaner way (I've seen situations where GOTOs were legitimately
used, but rarely in student code.)

> 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.

Ignorant OS bigots. Ignorant editor bigots.

> Is this a dangerous topic, or what?

No, it's a lot safer than "My editor can beat up your editor". Even that
is safer than "My shell can bash <g> in your shell."

> Nick ;-)

-- 

                        Shmuel (Seymour J.) Metz
                        Senior Software SE

The values in from and reply-to are for the benefit of spammers:
reply to domain eds.com, user msustys1.smetz or to domain gsg.eds.com,
user smetz.




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

* Re: Use of 'goto'
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Shmuel (Seymour J.) Metz @ 1997-07-03  0:00 UTC (permalink / raw)



Mike linnig wrote:
> 
> Spagetti code is bad, spagetti code uses gotos, therefore goto is bad.

A false conclusion from a false premise, even if you allow use of "pons
asinorum" (B, A=>B, therefore A). Spaghetti code need not use GOTO, and
some of the worst examples I've seen did not.

> I think training is a better way to make good code than arbitrary restrictions
> on easy to notice features. 

<dws>But there's no money in the budget for QA and training; we've put
it all 
into bug fixes, and don't understand why there are so many of
them.</dws>

 
> This raises the visibilty to the person responsible for
> getting the job done and 'teaches' the programmer that goto's are a construct
> that should not be used lightly.

IMHO *no* control sturcture should be used lightly; the programmer
should
understand what he is doing and why. Silly of me.

>    Mike Linnig

-- 

                        Shmuel (Seymour J.) Metz
                        Senior Software SE

The values in from and reply-to are for the benefit of spammers:
reply to domain eds.com, user msustys1.smetz or to domain gsg.eds.com,
user smetz.




^ 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