Click here to Skip to main content
16,011,947 members

Survey Results

The goto statement.   [Edit]

Survey period: 8 Jan 2001 to 14 Jan 2001

We want to finally put to rest the question of whether the goto statement is a Good Thing or a Bad Thing.

OptionVotes% 
It's a great thing. Can't live without it.111.60
It's handy if used correctly16724.31
It's just a piece of syntax - niether good nor bad.8612.52
I don't like it, but can see why it may be useful sometimes.25136.54
It's a Very Bad Thing17225.04



 
GeneralWho needs goto Pin
AlexMarbus7-Jan-01 21:12
AlexMarbus7-Jan-01 21:12 
GeneralRe: Who needs goto Pin
Gavin Greig8-Jan-01 3:37
Gavin Greig8-Jan-01 3:37 
GeneralRe: Who needs goto Pin
AlexMarbus8-Jan-01 5:19
AlexMarbus8-Jan-01 5:19 
GeneralRe: Who needs goto Pin
Gavin Greig8-Jan-01 22:37
Gavin Greig8-Jan-01 22:37 
GeneralRe: Who needs goto Pin
David Wulff8-Jan-01 5:42
David Wulff8-Jan-01 5:42 
GeneralRe: Who needs goto Pin
Christian Graus8-Jan-01 12:03
protectorChristian Graus8-Jan-01 12:03 
GeneralRe: Who needs goto Pin
David Wulff8-Jan-01 12:16
David Wulff8-Jan-01 12:16 
GeneralRe: Who needs goto Pin
John Fisher9-Jan-01 5:08
John Fisher9-Jan-01 5:08 
The complexity level would actually be the same (at least in my opinion). Simply place a try statement at the top of the function, close it with a catch containing the "ExitWithError:" code at the same place you put that code. Then replace your "goto ExitWithError;" lines with "throw xxx" statements. This would not require duplicating the "abort on error" code.

The try/catch alternative can actually improve things, too. If you need to pass information to the error handling code, you can just throw the information. With the goto statement, you'd have to manually create variables, set them before calling goto, and then check them in the error handling routine.

Anyway, goto isn't bad. I just think there are better ways, and that it is normally worth the effort to use the better way than the quick and easy way -- especially after you make those better ways into habits.

Smile | :)

John
GeneralRe: Who needs goto Pin
David Wulff9-Jan-01 9:43
David Wulff9-Jan-01 9:43 
GeneralRe: Who needs goto Pin
Christian Graus9-Jan-01 13:20
protectorChristian Graus9-Jan-01 13:20 
GeneralRe: Who needs goto Pin
8-Jan-01 11:53
suss8-Jan-01 11:53 
GeneralRe: Who needs goto Pin
9-Jan-01 16:09
suss9-Jan-01 16:09 
GeneralRe: Who needs goto Pin
coder847213-Jan-01 12:34
coder847213-Jan-01 12:34 
GeneralRe: Who needs goto Pin
MrLonely13-Jan-01 12:47
MrLonely13-Jan-01 12:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.