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 1 of 7 1234 ... LastLast
Results 1 to 15 of 122

Hybrid View

  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    The grand 'goto' poll

    Okay - it's not very grand at all but here goes - the purists among us would prefer a world without 'goto'. The pragmatists among us think that it's 'sometimes' the right tool for the job, so let's have a vote.

    How often have you used 'goto' in the last 5 years or so? Be honest - this is an anonymous poll so no-one needs to be embarrassed or fear for their reputation...! It's just a survey. No-one will get hung!

  2. #2
    Join Date
    Nov 2003
    Location
    Vienna, Austria
    Posts
    212
    I think once
    All the buzzt
    CornedBee

  3. #3
    Join Date
    Apr 1999
    Posts
    27,449
    A request for anyone voting that they use goto regularly in a C++ program:

    Please tell us the name of your software product(s) where you have used goto regularly.

    Regards,

    Paul McKenzie

  4. #4
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    Originally posted by Paul McKenzie
    A request for anyone voting that they use goto regularly in a C++ program:

    Please tell us the name of your software product(s) where you have used goto regularly.

    Regards,

    Paul McKenzie
    I use goto regularly when programming in C (for cleanup). I have probably also used it in C++, but the product I'm working with, is mostly written in C. It's a Windows security product (PKI), running on WinNT/2000/XP clients. The name is RSA Keon Desktop or TFS Desktop.

    /Jonas

  5. #5
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    Just as a side note. I performed a search on my entire VC++.NET directory for goto and it returned 2287 hits.

    TDM

  6. #6
    Join Date
    Mar 2004
    Location
    Central Florida
    Posts
    293

    Re: The grand 'goto' poll

    Quote Originally Posted by TDM
    Just as a side note. I performed a search on my entire VC++.NET directory for goto and it returned 2287 hits.

    TDM
    Microsoft should rarely be used as an example of good coding practice. I haven't used GoTo since I quite programming is QuickBasic 10 years ago.

  7. #7
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863

    Re: The grand 'goto' poll

    Heck I just want to be part of a goto thread, I have always admired these things...

    //As a side note.. I have never used goto, but I don't know why, It just seems to
    //have turned out that way. I think I am goig to put a goto into the C++ code I
    //am wrting right now, just because I don't like people telling me what to do, and
    //this goes double if the person is a Professor
    Last edited by souldog; September 28th, 2004 at 05:55 PM.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

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

    Re: The grand 'goto' poll

    Quite a few languages have "goto" statements and they may or may not be necessary depending on the structure of the language. Every assembly language I ever used had a goto and you needed to use it. There was no way around it. I believe Basic has a necessary goto also (I have very little experience with Basic). I can't remember if Fortran does or not (I haven't even seen Fortran since my college days).

    Goto is a part of C (and C++), but the structure of the language makes it unnecessary except for handling some extreme error conditions. The language has a better way of writing a program.

    There is some dogmatism about goto in C and C++, but there are some practical reasons for it too. Not only is a program listing more readable by a human without gotos, but I don't believe modern optimizing compilers won't optimize code with a lot of gotos very well, which will make the program run slower.

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

    Re: The grand 'goto' poll

    Hello??? Someone right there?
    Mmmmm... long time this thread has been inactive... and has not come to Holy War... maybe it did while I was away and then they were all nuked and no one survived to discuss gotos...

    Mmmm... I'm getting bored...

    This poll was getting SO good. Maybe we can restart this thread and get much more fun...

    Oh! I know how to do that:
    Code:
    goto "The grand 'goto' poll"
    You're not watching "24"?
    Well... you should.

    24
    Jack IS back...

  10. #10
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: The grand 'goto' poll

    Quote Originally Posted by TDM
    Just as a side note. I performed a search on my entire VC++.NET directory for goto and it returned 2287 hits.
    It just seems to be "non-optimized code, that is specifically designed for debugging purposes only. Have you find a single goto in any sample code available in MSDN?
    The required binaries, which are linked in Release mode, must not be having any gotos at all...
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  11. #11
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    Re: The grand 'goto' poll

    There may be reasons to use goto in C, where you don't have exception handling, but in C++ you do and they should be used instead.

    In C, the "goto" would actually replace the "throw" in C++ and the label would be the start of the "catch" block in C++.

    You can think of it as a poor-man's exception, as there are obviously clear limitations.

  12. #12
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: The grand 'goto' poll

    Quote Originally Posted by NMTop40
    In C, the "goto" would actually replace the "throw" in C++ and the label would be the start of the "catch" block in C++.
    Of course, C also used the rather frightening setjmp and longjmp for the same purpose. They always scared the **** out of me. I never used them once....
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  13. #13
    Join Date
    Jun 2001
    Location
    Switzerland
    Posts
    4,443

    Re: The grand 'goto' poll

    Quote Originally Posted by Ajay Vijay
    It just seems to be "non-optimized code, that is specifically designed for debugging purposes only. Have you find a single goto in any sample code available in MSDN?
    Yes, I unfortunately did...
    The required binaries, which are linked in Release mode, must not be having any gotos at all...
    Err...the binaries won't contain any C++ keyword, you know...If the symbols are stripped (as they normally are in release builds) then you won't see them either.
    Gabriel, CodeGuru moderator

    Forever trusting who we are
    And nothing else matters
    - Metallica

    Learn about the advantages of std::vector.

  14. #14
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: The grand 'goto' poll

    Gabriel,
    I meant that release versions of binaries (mfc42.dll, msvcrt.dll, ....) WAS not built using any 'gotos', and the source available to us is non-optimized one.

    Also I want to know where you became unfortunate?
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  15. #15
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: The grand 'goto' poll

    CDocManager::OnDDECommand(...) has quite a few goto's dotted about. In fact, even DllMain(..) in DllModul.cpp has a couple.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

Page 1 of 7 1234 ... 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