go_to what's in using them

A

av

Are you 'ab' of alt.lang.asm? If so, seemingly, you don't like
traditional assembler nor do you like C! Maybe you should start a group
for your private language, tons of whose source you regularly spam
a.l.a with...

tons of tons
 
J

John Bode

I keep hearing about not to use 'go_to' in your code. However, I don't
know what's the reasoning behind it?

Can any one here shed some light?

Thanks in advance,
Manish

Undisciplined use of goto (not go_to) can result in code that is
difficult to read and maintain. It can also inhibit certain compiler
optimizations, at least according to one of my references.

The main problem is that since a goto can branch either direction in a
function, it's possible to write code that doesn't "read" in a linear
fashion, making the code difficult to debug by inspection. It can also
lead to code that's "brittle", or difficult to modify. I saw one
abomination that had 13 or so gotos branching in random directions; it
literally took weeks to puzzle out the flow of control (granted, this
code had other problems, but the gotos made a bad situation
impossible).

There are times when a goto is useful, such as for breaking out of a
deeply nested loop, but more often than not it's better to stick with
the standard control structures (if, while, for, do) and unconditional
branch statements (break and continue).
 
T

Tor Rustad

I keep hearing about not to use 'go_to' in your code. However, I don't
know what's the reasoning behind it?

Can any one here shed some light?

See C FAQ 17.10
 
E

Ed Prochak

Walter said:
Ed Prochak said:
However even Wirth did not propose complete elimination of GOTO. Wirth
created PASCAL and still included GOTO. His chief use of GOTO was error
handling. The goal of the Structured Programming movement is often
mistakenly described as seaking GOTOless programming. Such a
description is wrong. It was the UNRESTRAINED use of goto that they
sought to eliminate.

Your analysis disagrees with Wirth's own published works.

http://www.swissdelphicenter.ch/en/niklauswirth.php

Yet, Pascal also suffered from certain deficiencies, more or
less significant depending on personal perception and
application. [...]

Certain other deficiencies were due to the author's lack of
courage to throw some rules inherited from Algol over board, in
fear of antagonizing influential Algol programmers. The prime
entry in this list is the famed go to statement, retained
although, in principle, always replaceable by an if, while, or
repeat construct

Interesting. I alway thought he was not of that radical camp. I based
my judgement on his textbook: Algorithms+DataStructures=Programs
I remember at least one of the programs in the book used goto. And
while goto is "in principle, always replaceable by an if, while, or
repeat construct", without an error handling mechanism (like EXCEPTION)
in the language, goto can be very useful. Otherwise the nesting of
error checking IF statements gets tedious and nearly as error prone as
the goto.

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top