Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Since goto is getting so popular these days....

Since goto is getting so popular these days....

Scheduled Pinned Locked Moved The Lounge
questionlinuxtoolshelp
41 Posts 31 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Marc Clifton

    rastaVnuce wrote:

    elegantly solvable by using goto

    "elegant" and "goto" should not be in the same sentence. ;) Marc

    K Offline
    K Offline
    kevinnicol
    wrote on last edited by
    #11

    Unless the sentence is "how to elegeantly fire that coder who keeps using goto's in his code."

    1 Reply Last reply
    0
    • R rastaVnuce

      I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

      We are using Linux daily to UP our productivity - so UP yours!

      T Offline
      T Offline
      Tomz_KV
      wrote on last edited by
      #12

      "GOTO" is a good statement in sql that cannot be easily replaced.

      TOMZ_KV

      1 Reply Last reply
      0
      • R rastaVnuce

        I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

        We are using Linux daily to UP our productivity - so UP yours!

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #13

        While I would not normally consider using the force for negative purposes, I'm seriously considering making your lower intestines leak out of your left ear just for suggesting it.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        1 Reply Last reply
        0
        • R rastaVnuce

          I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

          We are using Linux daily to UP our productivity - so UP yours!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #14

          I've NEVER held a religious view about goto. I do agree that overuse can make code unreadable. I've never used goto in my code, in 12 or so years of programming, because it's never been the best solution.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          G F 2 Replies Last reply
          0
          • R rastaVnuce

            I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

            We are using Linux daily to UP our productivity - so UP yours!

            T Offline
            T Offline
            Tom Delany
            wrote on last edited by
            #15

            I've heard some claim that it is valid if you're writing a state machine. Personally, I avoid goto like the plague!

            WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated. There are 10 kinds of people in the world: People who know binary and people who don't.

            M 1 Reply Last reply
            0
            • R rastaVnuce

              I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

              We are using Linux daily to UP our productivity - so UP yours!

              M Offline
              M Offline
              Mark_Wallace
              wrote on last edited by
              #16

              Is the goto becoming popular? How silly. It's just a tool, just like any other keyword used for a predefined function. Mind you, I'm still pissed off that the C+ chaps refused my demand to have the return statement keyword changed to "otog" -- symmetry is so important in programming; it makes everything more understandable.

              I wanna be a eunuchs developer! Pass me a bread knife!

              R 1 Reply Last reply
              0
              • T Tom Delany

                I've heard some claim that it is valid if you're writing a state machine. Personally, I avoid goto like the plague!

                WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated. There are 10 kinds of people in the world: People who know binary and people who don't.

                M Offline
                M Offline
                Mike Marynowski
                wrote on last edited by
                #17

                If you look at the state machine class that is automatically generated for a method that uses the C# yield return keyword, you will find goto statements. I think it would be brutally messy to implement otherwise.

                1 Reply Last reply
                0
                • R rastaVnuce

                  I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

                  We are using Linux daily to UP our productivity - so UP yours!

                  B Offline
                  B Offline
                  BillWoodruff
                  wrote on last edited by
                  #18

                  One-time-only, or occasional, use of 'goto will simply intensify the awareness of the Hell you are already in, but if used recursively, 'goto renders you fully aware of said Hell, and thus unable to reboot your consciousness. best, Bill

                  "Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844

                  1 Reply Last reply
                  0
                  • M Mark_Wallace

                    Is the goto becoming popular? How silly. It's just a tool, just like any other keyword used for a predefined function. Mind you, I'm still pissed off that the C+ chaps refused my demand to have the return statement keyword changed to "otog" -- symmetry is so important in programming; it makes everything more understandable.

                    I wanna be a eunuchs developer! Pass me a bread knife!

                    R Offline
                    R Offline
                    Rob Grainger
                    wrote on last edited by
                    #19

                    Busog shurely

                    M 1 Reply Last reply
                    0
                    • R Rob Grainger

                      Busog shurely

                      M Offline
                      M Offline
                      Mark_Wallace
                      wrote on last edited by
                      #20

                      Please don't call me Shurely.

                      I wanna be a eunuchs developer! Pass me a bread knife!

                      1 Reply Last reply
                      0
                      • R rastaVnuce

                        I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

                        We are using Linux daily to UP our productivity - so UP yours!

                        R Offline
                        R Offline
                        rastaVnuce
                        wrote on last edited by
                        #21

                        Why the bunch of univotes? Geeezzz... Guys.. joke, you know... the thing you do / say to have a laugh? I know some don't understand that concept, hence the Joke icon... :doh: Aaah... goto hell!

                        We are using Linux daily to UP our productivity - so UP yours!

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          I've NEVER held a religious view about goto. I do agree that overuse can make code unreadable. I've never used goto in my code, in 12 or so years of programming, because it's never been the best solution.

                          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                          G Offline
                          G Offline
                          Gary Wheeler
                          wrote on last edited by
                          #22

                          Christian Graus wrote:

                          I've never used goto in my code, in 12 or so years of programming

                          The last time I used goto was back in the early 90's, and then it was because exception handling wasn't implemented by the tool chain I had at the time.

                          Software Zen: delete this;

                          1 Reply Last reply
                          0
                          • C Christian Graus

                            I've NEVER held a religious view about goto. I do agree that overuse can make code unreadable. I've never used goto in my code, in 12 or so years of programming, because it's never been the best solution.

                            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                            F Offline
                            F Offline
                            Fabio Franco
                            wrote on last edited by
                            #23

                            Never used GOTO writing MS-DOS batch files? Ok, I was 15 years old, but still, by then it was reasonable.

                            1 Reply Last reply
                            0
                            • M Marc Clifton

                              rastaVnuce wrote:

                              elegantly solvable by using goto

                              "elegant" and "goto" should not be in the same sentence. ;) Marc

                              P Offline
                              P Offline
                              pboucher
                              wrote on last edited by
                              #24

                              lol, completely agree with you on this one.

                              Pierre Boucher 'Bien souvent on se rend coupable en négligeant d'agir, et non pas seulement en agissant.' - Marc Aurèle, empereur et philosophe romain.

                              1 Reply Last reply
                              0
                              • R rastaVnuce

                                I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

                                We are using Linux daily to UP our productivity - so UP yours!

                                C Offline
                                C Offline
                                Carlos Adriano Portes
                                wrote on last edited by
                                #25

                                Event though I do not use it I've heard it is useful in some scenarios since it does not backtrack the method execution, it was used in the past on single entry single exit methods.

                                1 Reply Last reply
                                0
                                • R rastaVnuce

                                  I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

                                  We are using Linux daily to UP our productivity - so UP yours!

                                  T Offline
                                  T Offline
                                  tsafdrabytrals
                                  wrote on last edited by
                                  #26

                                  No, you will not go to hell. You will go blind though.

                                  1 Reply Last reply
                                  0
                                  • R rastaVnuce

                                    I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

                                    We are using Linux daily to UP our productivity - so UP yours!

                                    J Offline
                                    J Offline
                                    jsrjsr
                                    wrote on last edited by
                                    #27

                                    But you will spend a century in purgatory...

                                    1 Reply Last reply
                                    0
                                    • R rastaVnuce

                                      I have a problem which is elegantly solvable by using goto. Will I goto hell if I use it? Disclaimer: This is not a programming question, it is a religious / philosophical one.

                                      We are using Linux daily to UP our productivity - so UP yours!

                                      K Offline
                                      K Offline
                                      Kenneth Kasajian
                                      wrote on last edited by
                                      #28

                                      Ignore people who say goto is bad. Don't use goto when it's bad. It should be clear to you when that is. Don't use goto when there's already a language construct that can be used *just as easily*. One place where I use goto without apology is to simulate a finally clause when exception handling is not part of the language, or is non standard. For instance, in C. It's a matter of style, but I prefer the second version below: BEFORE:

                                      void far()
                                      {
                                      int error;
                                      Resource *r1 = NULL, *r2 = NULL, *r3 = NULL;

                                      error = somefunc1(...., &r1);
                                      if ( !error )
                                      {
                                          ....
                                          error = somefunc2(...., &r2);
                                          if ( !error )
                                          {
                                              ....
                                              error = somefunc2(...., &r3);
                                              if ( !error )
                                              {
                                                  ....
                                      
                                                  free( r3 );
                                              }
                                      
                                              free( r2 );
                                          }
                                      
                                          free( r1 );
                                      }
                                      

                                      }

                                      AFTER:

                                      void far()
                                      {
                                      int error;
                                      Resource *r1 = NULL, *r2 = NULL, *r3 = NULL;

                                      error = somefunc1(...., &r1);
                                      if ( !error )
                                          goto error:
                                      
                                      ....
                                      
                                      error = somefunc2(...., &r2);
                                      if ( !error )
                                          goto error:
                                      
                                      ....
                                      
                                      error = somefunc3(...., &r3);
                                      if ( !error )
                                          goto error:
                                      
                                      ....
                                      

                                      error:
                                      if ( r1 )
                                      free( r1 );
                                      if ( r2 )
                                      free( r2 );
                                      if ( r3 )
                                      free( r3 );
                                      }

                                      Yes, the second form can be constructed without the goto, by using a gated if along the way, but having all the clean up code in a single place is a nice feature.

                                      ken@kasajian.com / www.kasajian.com

                                      D J 2 Replies Last reply
                                      0
                                      • K Kenneth Kasajian

                                        Ignore people who say goto is bad. Don't use goto when it's bad. It should be clear to you when that is. Don't use goto when there's already a language construct that can be used *just as easily*. One place where I use goto without apology is to simulate a finally clause when exception handling is not part of the language, or is non standard. For instance, in C. It's a matter of style, but I prefer the second version below: BEFORE:

                                        void far()
                                        {
                                        int error;
                                        Resource *r1 = NULL, *r2 = NULL, *r3 = NULL;

                                        error = somefunc1(...., &r1);
                                        if ( !error )
                                        {
                                            ....
                                            error = somefunc2(...., &r2);
                                            if ( !error )
                                            {
                                                ....
                                                error = somefunc2(...., &r3);
                                                if ( !error )
                                                {
                                                    ....
                                        
                                                    free( r3 );
                                                }
                                        
                                                free( r2 );
                                            }
                                        
                                            free( r1 );
                                        }
                                        

                                        }

                                        AFTER:

                                        void far()
                                        {
                                        int error;
                                        Resource *r1 = NULL, *r2 = NULL, *r3 = NULL;

                                        error = somefunc1(...., &r1);
                                        if ( !error )
                                            goto error:
                                        
                                        ....
                                        
                                        error = somefunc2(...., &r2);
                                        if ( !error )
                                            goto error:
                                        
                                        ....
                                        
                                        error = somefunc3(...., &r3);
                                        if ( !error )
                                            goto error:
                                        
                                        ....
                                        

                                        error:
                                        if ( r1 )
                                        free( r1 );
                                        if ( r2 )
                                        free( r2 );
                                        if ( r3 )
                                        free( r3 );
                                        }

                                        Yes, the second form can be constructed without the goto, by using a gated if along the way, but having all the clean up code in a single place is a nice feature.

                                        ken@kasajian.com / www.kasajian.com

                                        D Offline
                                        D Offline
                                        Dan Neely
                                        wrote on last edited by
                                        #29

                                        will C let you use error as both a variable and a label?

                                        3x12=36 2x12=24 1x12=12 0x12=18

                                        1 Reply Last reply
                                        0
                                        • M Marcus_Idle

                                          I get that this is a joke question, but seriously, why so much debate about it? It messes with flow in a pretty unreadable way, and the whole point of modern (post 1950) computer languages is that you write for your colleagues (or your future self) so why do it? But we've all seen a lot worse[^], so goto isn't the devil incarnate... end of story(?)

                                          J Offline
                                          J Offline
                                          Jeff Connelly
                                          wrote on last edited by
                                          #30

                                          "It messes with flow in a pretty unreadable way"? Really? You find a goto statement unreadable? It really doesn't get much easier to understand than a goto statement. As easy, or easier, than a function call (a function call could be in a place further away in the code, and thus slightly harder to track down, while a goto, if not done poorly, will be very close by.) This gets pretty silly. There's nothing inherently wrong with goto. This comes from efforts in the distant past to clean up spaghetti code - one of the tenets of "structured coding". From wikipedia: "Donald Knuth accepted the principle that programs must be written with provability in mind, but he disagreed (and still disagrees[citation needed]) with abolishing the GOTO statement. In his 1974 paper, "Structured Programming with Goto Statements", he gave examples where he believed that a direct jump leads to clearer and more efficient code without sacrificing provability." There's another "rule" to have only 1 exit point from a procedure. Yet this can lead to badly structured (unreadable, unmaintainable), deeply nested if statements, especially where return code and error handling are concerned. Lacking a quick "return" call, I think a "goto" to an exit line would be appropriate. switch statements are glorified gotos, as are multiple return statements (just debug the procedure if you doubt that :-) )

                                          I 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups