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. do you use goto? [modified]

do you use goto? [modified]

Scheduled Pinned Locked Moved The Lounge
phphtmldatabaseoraclecom
65 Posts 41 Posters 0 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.
  • P Patrick Klug

    Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

    Listen to the toad! www.dotnettoad.com[^]

    modified on Monday, May 19, 2008 4:44 AM

    L Offline
    L Offline
    leckey 0
    wrote on last edited by
    #51

    Goto's are evil and real programmers never use them.

    Shhhhh..... http://craptasticnation.blogspot.com/[^]

    1 Reply Last reply
    0
    • P Patrick Klug

      Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

      Listen to the toad! www.dotnettoad.com[^]

      modified on Monday, May 19, 2008 4:44 AM

      R Offline
      R Offline
      Ri Qen Sin
      wrote on last edited by
      #52

      I use label: … goto label whenever I have to use while (true) { … }

      So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?

      J 1 Reply Last reply
      0
      • R Robert Rohde

        Philip Laureano wrote:

        Rule #1: Don't use goto. Rule #2: Know when to break Rule #1. Rule #3: Never goto #2.

        Do you like recursion? :) Rule #4: Know when to break Rule #3. Rule #5: Never goto #4 Rule #6: Know when to break Rule #5. ... Robert

        S Offline
        S Offline
        Steve Hansen
        wrote on last edited by
        #53

        To learn recursion you first need to know recursion!

        1 Reply Last reply
        0
        • L leppie

          And now I will turn you into a frog! POOF!

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 3 out now

          B Offline
          B Offline
          BadKarma
          wrote on last edited by
          #54

          Thanks allot leppie :mad: now i'm forced to make jumps :laugh:

          Learn from the mistakes of others, you may not live long enough to make them all yourself.

          L enhzflepE 2 Replies Last reply
          0
          • P Patrick Klug

            Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

            Listen to the toad! www.dotnettoad.com[^]

            modified on Monday, May 19, 2008 4:44 AM

            J Offline
            J Offline
            John M Drescher
            wrote on last edited by
            #55

            I have less than 5 gotos in the 500K+ lines of code I have written in the last 10 years so its quite rare for me.

            John

            1 Reply Last reply
            0
            • P Patrick Klug

              Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

              Listen to the toad! www.dotnettoad.com[^]

              modified on Monday, May 19, 2008 4:44 AM

              N Offline
              N Offline
              Nemanja Trifunovic
              wrote on last edited by
              #56

              Pakl wrote:

              I am interested if you are using goto's

              No, but I reserve the right to use it and not feel bad.

              Programming Blog utf8-cpp

              1 Reply Last reply
              0
              • R Rajesh R Subramanian

                1. switch works only with integral types and so it cannot be used everywhere. 2. switch uses goto internally.

                Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

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

                if uses goto internally. while uses goto internally. for uses goto internally. function calls use goto internally. Your CPU only knows goto internally. There's a reason why modern programming languages provide a collection of wrappers to hide goto from you.

                You know, every time I tried to win a bar-bet about being able to count to 1000 using my fingers I always got punched out when I reached 4.... -- El Corazon

                1 Reply Last reply
                0
                • P Patrick Klug

                  Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

                  Listen to the toad! www.dotnettoad.com[^]

                  modified on Monday, May 19, 2008 4:44 AM

                  A Offline
                  A Offline
                  Alan Balkany
                  wrote on last edited by
                  #58

                  I haven't used a goto in 25 years of programming, but I like the option to be available in case I need it. It's been claimed that a goto is useful for exiting deeply-nested code when an error is detected. But in the evolution of my programming style, my methods have become much shorter and only rarely have deep nesting. I can only think of two occasions a goto was necessary. One was when I encountered a bug in IBM's PL/I compiler back in the 1980s, and I needed a goto to force sequential execution. (The next statement wasn't being executed.) The other time was in grad school in the 1990s when I was implementing a system that translated a flow graph drawn on the screen into C code. Each mechanism (a box on the screen representing a library component) was assigned a label, and gotos were part of the automatically-generated template for sequencing their execution. A goto would also be useful for a rapid fix under time pressure. It's good that gotos are discouraged. They're easy and the temptation to use them is great for that reason. (I used them constantly in BASIC when I first learned to program.) But code is already complex enough without making it more complex with abrupt changes in flow.

                  1 Reply Last reply
                  0
                  • B BadKarma

                    Thanks allot leppie :mad: now i'm forced to make jumps :laugh:

                    Learn from the mistakes of others, you may not live long enough to make them all yourself.

                    L Offline
                    L Offline
                    leppie
                    wrote on last edited by
                    #59

                    Haha, I didnt mean it like that, but go ahead :)

                    xacc.ide - now with TabsToSpaces support
                    IronScheme - 1.0 alpha 3 out now

                    1 Reply Last reply
                    0
                    • R Rage

                      fboule wrote:

                      the MS-DOS batch script below

                      If under XP, then use a for loop to do that.

                      ~RaGE();

                      I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
                      Do not feed the troll ! - Common proverb

                      F Offline
                      F Offline
                      fboule
                      wrote on last edited by
                      #60

                      It was only a simple example. It could be a more complex loop, like for a user menu or something else...

                      1 Reply Last reply
                      0
                      • P Patrick Klug

                        Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

                        Listen to the toad! www.dotnettoad.com[^]

                        modified on Monday, May 19, 2008 4:44 AM

                        R Offline
                        R Offline
                        Roger Wright
                        wrote on last edited by
                        #61

                        I haven't used a GOTO in a long time, though it was perfectly natural to use it when there was little else available. Considering that I started with JP, JZ, JNZ, etc, GOTO seemed a logical next step. Now that modern languages include so many more functional constructs, it would be difficult to find a reason for using GOTO. I suspect that, if the need existed, it would be due to timing/memory constraints and I'd be smarter to go back to Assembly code to optimize the routine. That being said, I don't consider the use of GOTO bad form, if it's appropriate to the problem at hand - a state machine implementation, for instance.

                        "A Journey of a Thousand Rest Stops Begins with a Single Movement"

                        1 Reply Last reply
                        0
                        • R Ri Qen Sin

                          I use label: … goto label whenever I have to use while (true) { … }

                          So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?

                          J Offline
                          J Offline
                          Jorgen Andersson
                          wrote on last edited by
                          #62

                          Break?

                          1 Reply Last reply
                          0
                          • P Patrick Klug

                            Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

                            Listen to the toad! www.dotnettoad.com[^]

                            modified on Monday, May 19, 2008 4:44 AM

                            P Offline
                            P Offline
                            PIEBALDconsult
                            wrote on last edited by
                            #63

                            An occasional goto case in C#. Otherwise not since I advanced from BASIC.

                            1 Reply Last reply
                            0
                            • P Patrick Klug

                              Hey guys, My former team mate used goto's quite often (to my despair). I just published a small post on when to (not) use goto on my blog[^] where I try to look at this in a pragmatic way. I am interested if you are using goto's (or know someone who does?). Opinions? cheers, Pakl PS: This is just a blunt advertisment for my blog so I can lure you into it and become rich and famous. :-\

                              Listen to the toad! www.dotnettoad.com[^]

                              modified on Monday, May 19, 2008 4:44 AM

                              R Offline
                              R Offline
                              Robert Royall
                              wrote on last edited by
                              #64

                              I've had to use GOTO for programming Access/VB6 forms when doing error handling. It was basically a poor man's version of the Finally block, used to clean up objects or database connections/recordsets. I don't think I've ever had any other instances where it was appropriate.

                              Imagine that you are hired to build a bridge over a river. The river gets slightly wider every day; sometimes it shrinks but nobody can predict when. Your contract says you can't use concrete or steel - the client only provides timber and cut stone (but won't tell you what kind). Gravity changes from hour to hour, as does the viscosity of air. Your only tools are a hacksaw, a chainsaw, a rubber mallet, and a length of rope. Welcome to my world. -Me explaining my job to an engineer

                              1 Reply Last reply
                              0
                              • B BadKarma

                                Thanks allot leppie :mad: now i'm forced to make jumps :laugh:

                                Learn from the mistakes of others, you may not live long enough to make them all yourself.

                                enhzflepE Offline
                                enhzflepE Offline
                                enhzflep
                                wrote on last edited by
                                #65

                                short jmps, long jmps, near jmps or far jmps?

                                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