Why doesn't anyone use a goto statement anymore?
where ever you put goto name; it will go to any section with
name:
So for example.
BLOCK OF CODE HERE
goto name;
BLOCK OF CODE
BLOCK OF CODE
name:
(It would then start at the next block of code after name.)
BLOCK OF CODE
This will work up or down. For example.
mainMenu:
BLOCK OF CODE
BLOCK OF CODE
BLOCK OF CODE
goto mainMenu;
Why doesn't anyone use Goto anymore?
Started by Donovan, Sep 09 2009 08:39 AM
21 replies to this topic
#1
Posted 09 September 2009 - 08:39 AM

+Friend Me | My Graphics | Forum Rules | Help Forum | Forum FAQ
|
|
|
#2
Posted 09 September 2009 - 10:20 AM
Because other programming structures largely make goto kludgey and irrelevant, relegating "proper" use of goto to very few situations. The ones you show are not them. ;)
#3
Posted 09 September 2009 - 10:27 AM
Goto also can't be used to go into a try statement, making it's practical use in C++ very limited.
Goto is also difficult to read, since there's no way for you to know where that label is short of some kind of very detailed IDE.
I believe there may be uses for Goto... I've just never seen them.
Goto is also difficult to read, since there's no way for you to know where that label is short of some kind of very detailed IDE.
I believe there may be uses for Goto... I've just never seen them.
Wow I changed my sig!
#4
Posted 09 September 2009 - 11:41 AM
An article I stumbled upon: Code Complete, First Edition
#5
Posted 09 September 2009 - 12:35 PM
I used to use it a lot in basicA
and occasionally in QuickBasic,
since then I haven't used it.
(whoops... showing my age)
and occasionally in QuickBasic,
since then I haven't used it.
(whoops... showing my age)
#6
Posted 09 September 2009 - 01:07 PM
QuickBasic... the good old days when you could start a loop at 0 and poke 0 into the loop variable :) Until DOS froze, that is.
#7
Posted 09 September 2009 - 03:18 PM
I think goto just makes it terribly hard to read and maintain code. Structured programming took over.
#8
Posted 09 September 2009 - 04:48 PM
WingedPanther said:
QuickBasic... the good old days when you could start a loop at 0 and poke 0 into the loop variable :) Until DOS froze, that is.
wanted on the bits of your printer port w/ only 1 command!!
The good old days... :D
#9
Posted 09 September 2009 - 05:20 PM
People don't use goto because of the very good reasons given by Edsger Dijkstra in his article: "Goto Statement Considered Harmful".
I think the only justifiable gotos in C are in lieu of exceptions. In any case, one should just use setjmp.h
I think the only justifiable gotos in C are in lieu of exceptions. In any case, one should just use setjmp.h
#10
Posted 09 September 2009 - 05:55 PM
One thing that I forget to keep in mind when developing is that I may not always be the person working on the code I'm writing. This sometimes results in code that is messy and hard to maintain due to bad naming, structure, or lack of clear comments.
-CDG10620
Software Developer
Software Developer
#12
Posted 10 September 2009 - 02:07 AM
Goto can make code hard to follow, or drag functions out when it could be split into two (or more) functions. It can also make modifying code hard. IMO.
Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!


Sign In
Create Account


Back to top










