How to understand GoTo's document note?

Just starting out? Need help? Post your questions and find answers here.
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: How to understand GoTo's document note?

Post by Little John »

luis wrote:
They should be avoided and maybe should use compiler warnings to make this clear.
That would be really a ridiculous thing.
Hi luis,

I agree.

The problem is not Goto itself, the problem is that Goto is very often abused, producing unreadable spaghetti code.
It's like using a sharp scalpel: an experienced surgeon knows when and how to use it properly. But when untrained people use it all the time anywhere and anyhow, nothing good comes out of it.
[u]Dijkstra[/u] wrote:The go to statement as it stands [...] is too much an invitation to make a mess of one's program.
Unfortunately, too many people cannot resist this invitation ...
At least the documentation of Goto should cointain in bold letters: For advanced programmers only.
User avatar
GedB
Addict
Addict
Posts: 1312
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Re: How to understand GoTo's document note?

Post by GedB »

Little John wrote: The problem is not Goto itself, the problem is that Goto is very often abused, producing unreadable spaghetti code.
It's like using a sharp scalpel: an experienced surgeon knows when and how to use it properly. But when untrained people use it all the time anywhere and anyhow, nothing good comes out of it.
To quote M Jackson, author of the 1975 book Principles of Software Design:
Unfortunately, a catchy and easily remembered headline “GO-TO Statement
Considered Harmful” was added to Dijkstra’s letter to the Communications of the ACM
(1968). As his ideas spread, they became diluted and oversimplified; it seemed attractive to
encapsulate the whole matter in a single-minded ban on the GO-TO statement, presenting a
complex intellectual issue as a readily understood slogan. Control flow is a complex issue....

To identify Structured Programming with the avoidance of the GO-TO statement is
simplistic, and traduces the depth and importance of the ideas involved. But such an
identification has been widely made, and has had an eccentric effect on the comparative
evaluation of programming languages. Attention has been concentrated on a minor issue of
superficial syntax, on whether a particular language allows repetition and selection to be
expressed without resorting to the condemned GO-TO, and has thus been drawn away
from more significant questions.
https://pdfs.semanticscholar.org/ab8a/2 ... 8210cf.pdf
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: How to understand GoTo's document note?

Post by Little John »

Hi GedB,

thanks for the quote by M. Jackson.
No doubt, control flow is a complex issue. Anyway, after having read literally Gigabytes of source code written in Basic during the last 20 years, I'm convinced that as far as Goto is concerned, the core problem is exactly described by my text that you quoted.
Post Reply