CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

View Poll Results: How often have you used 'goto' in the last 5 years?

Voters
111. You may not vote on this poll
  • I use goto regularly.

    3 2.70%
  • I use goto occasionally.

    8 7.21%
  • I've used goto VERY occasionally.

    34 30.63%
  • I've never used goto at all.

    66 59.46%
Page 6 of 9 FirstFirst ... 3456789 LastLast
Results 76 to 90 of 122
  1. #76
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

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

  2. #77
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    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.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  3. #78
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212

    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

  4. #79
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    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
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  5. #80
    Join Date
    Mar 2004
    Location
    Temuco, CHILE
    Posts
    161

    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?

  6. #81
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    1,342

    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.

  7. #82
    Join Date
    Jan 2004
    Location
    Near Portland, OR
    Posts
    222

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

  8. #83
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    Re: The grand 'goto' poll

    Quote 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.
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

  9. #84
    Join Date
    Jan 2004
    Location
    Near Portland, OR
    Posts
    222

    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!

  10. #85
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    Re: The grand 'goto' poll

    Quote 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 .
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

  11. #86
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    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.

  12. #87
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: The grand 'goto' poll

    For the love of <insert mythical creature here> please let this thread die...

  13. #88
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: The grand 'goto' poll

    Quote 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"?

  14. #89
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    Re: The grand 'goto' poll

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

  15. #90
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    Re: The grand 'goto' poll

    Quote Originally Posted by Mick
    For the love of <insert mythical creature here> please let this thread die...
    Just close the darn thing...
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

Page 6 of 9 FirstFirst ... 3456789 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured