View Poll Results: How often have you used 'goto' in the last 5 years?
- Voters
- 111. You may not vote on this poll
-
September 20th, 2004, 11:20 AM
#76
Re: The grand 'goto' poll
* disintering the topic out of the place where it should lie
Nobody mentioned the very serious problems that can occur when using goto's (and corresponding non-problems that can lead to need in goto's).
As many times said in this topic, goto makes you difficult to understand the control/data flow. And how difficult does it make some automatic tool to understand that? For example, optimizing compiler, verification tool (that can find a plenty of serious logical/security errors in 2000000 lines of code in several minutes if that code was written properly)? Testing tools that can produce testing procedures based on specification and the same code to catch some errors that no rational time of experiencing or verification-by-hand of software can detect?
End of all: it even would be difficult to obfuscate that programm with some obsufcation utility bacause it requires changing of control and data flow and so requires fine understanding of it!
Of course you can write the programm with goto's right way so there would be no irreducible control graph, but using goto you can lead it to that awkward state I mentioned above...
Next: what is the cause of using goto's mentioned?
Breaking from deep loops... Well, if you use extra flag variable to do so and do not use "bad" goto's, optimizing compiler will build your programm in such a way that there would be actually no flag and you will lose no efficacy at all.
Handling exceptions: as it was suggested you can always use do{...}while(0) or return value technique.
Any other resons?
For try..catch mechanism. It is also a nightmare for compiler. And for programmer too. What if you created that exception passing by throw using RAII? It would be destroyed before handled. What about saving some data on exit (on destruction)? It would be saved in disintegrated state while lifting up the stack in hope of finding "catch". And that dependance of well documentation as well...
"Programs must be written for people to read, and only incidentally for machines to execute."
-
September 20th, 2004, 12:00 PM
#77
Re: The grand 'goto' poll
I really think that the serious problems were mentioned. I think they were especially mentioned in indirect ways.
Did you read the articles about gotos? They are old but they are relevant and important classics. I forget the titles; something about gotos are considered harmful and I know there are links to the articles in previous messages in this thread. They say the things you are saying and clearly enough that many of us did not consider it necessary to repeat what they say.
Are you familiar with Structured Programming as a specific methodology? It is the methodology, for example, that is part of the definition of the design of the Pascal language. One reason the methodolgy was developed was to overcome the serious problems of gotos. So the previous comments about Structured Programming are relevant to what you are talking about.
There are books about Structured Programming; I don't know if they describe the problems that Structured Programming solves, but they probably do in some very relevant ways.
I recall that I said something about programmers having a strong emotional negative reaction to gotos. I think that is also relevant, although it is not as clear as it could be.
-
September 20th, 2004, 12:43 PM
#78
Re: The grand 'goto' poll
What if you created that exception passing by throw using RAII?
That would be pretty stupid...
All the buzzt
CornedBee
-
September 20th, 2004, 01:27 PM
#79
Re: The grand 'goto' poll
I do not like and use 'goto' because I had to learn Assembler for one year now, and all these jmp, jne, je, jz, jnz, jc, jnc ... So I try to write plain and easy understandable code
-
September 24th, 2004, 12:20 PM
#80
Re: The grand 'goto' poll
Hi!
I've used goto a lot in C, to escape sub-"main menus" in my applications ("hi, CONIO fan" and things like that). Thus one, or maybe two, goto's per program. Always together and easily visible anyway. Always in main. Always nowhere else to go. I got used to it because I also used 'em in BASIC to escape menus, but back then I placed a goto everywhere I could (mostly because if its silly error checking methods).
Since i'm working in C++, i've left goto's in the memento box, but I think that, given the case, that would have to be a very TERRIFIC program to be unsolved with what C++ offers, I would use it again.
Still, I think goto's are not bad, just... incompetent (ala "humans 're not evil, just... uninformed") for what it should had to be used. I haven't ever reccommended using goto's to my former students (i'm assisting student in the computer lab).
I like this chit-chat about the goto thing, bringing me some memories of the past. Hope it does not evolve into one of these Holy Wars. Or... did it?
-
September 24th, 2004, 12:52 PM
#81
Re: The grand 'goto' poll
I use it only, ONLY, for debugging purposes. I have never used it in a final program and never will and believe that generally it should never be used.
-
September 24th, 2004, 02:31 PM
#82
Re: The grand 'goto' poll
I think I used goto once when I was just learning C back in the 1980s. I then had to maintain a program written by someone who *loved* goto. I spent months rewriting his code to make it more readable (and eliminating his blown pointers and memory leaks).
-
September 24th, 2004, 03:48 PM
#83
Re: The grand 'goto' poll
Originally Posted by wdolson
I think I used goto once when I was just learning C back in the 1980s. I then had to maintain a program written by someone who *loved* goto. I spent months rewriting his code to make it more readable (and eliminating his blown pointers and memory leaks).
Ouch... you have my sympathies.
-
September 24th, 2004, 05:23 PM
#84
Re: The grand 'goto' poll
YourSurrogateGod:
Ouch... you have my sympathies.
The upside was that managing that code made me a much better programmer. I learned a lot of things *not* to do and why!
-
September 24th, 2004, 06:01 PM
#85
Re: The grand 'goto' poll
Originally Posted by wdolson
The upside was that managing that code made me a much better programmer. I learned a lot of things *not* to do and why!
There's a flip-side to everything in life . Like me realizing that it's a good thing that I have limited funds, because I would spend it all on Guinness .
-
September 25th, 2004, 09:21 AM
#86
Re: The grand 'goto' poll
I wonder how long people will still continue discussing this old subject. What amuses me most is how rigid and dogmatic most people get when it comes to gotos... After all, Dijkstra's famous paper was written way back in 1968, and we have already been taught at school why the structured programming paradigm tried to avoid gotos.
As a sidenote: During a compiler design class at university, we had to modify and extend the source code of a compiler for a language called "MiniPascal". The compiler itself was written in Pascal, and the author was nobody else than Prof. Nikolaus Wirth, the creator of Pascal and Modula 2 and one of the strongest advocates of structured programming. And guess what - his code was full of gotos (mainly for error handling). At that time, I found that fact both funny and revealing. Later, I understood that the most important point about the entire goto-discussion was to avoid beeing too dogmatic. Or, with other words: I guess that I didn't use a single goto statement in my own code since the days of BASIC (that's almost 20 years ago). Not that I tried hard to avoid them - they just weren't necessary. However, if I would run into the need to use a goto statement tomorrow, I wouldn't hesitate doing so.
For the interested, there's another very amusing (and long) thread on that subject, also known as The Famous Goto Thread. If you find the time to read it, pay special attention to galathaea's sudden illumination...
Last edited by gstercken; September 25th, 2004 at 09:37 AM.
-
September 25th, 2004, 09:59 AM
#87
Re: The grand 'goto' poll
For the love of <insert mythical creature here> please let this thread die...
-
September 25th, 2004, 10:20 AM
#88
Re: The grand 'goto' poll
Originally Posted by Mick
For the love of <insert mythical creature here> please let this thread die...
How about publishing a paper with the subject "Goto Discussion Threads Considered Harmful"?
-
September 25th, 2004, 10:23 AM
#89
Re: The grand 'goto' poll
Originally Posted by gstercken
How about publishing a paper with the subject "Goto Discussion Threads Considered Harmful"?
I would...but the hippies stole all my paper...
-
September 25th, 2004, 11:14 AM
#90
Re: The grand 'goto' poll
Originally Posted by Mick
For the love of <insert mythical creature here> please let this thread die...
Just close the darn thing...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|