Click here to Skip to main content

Welcome to the Lounge


For lazing about and discussing anything in a software developer's life that takes your fancy except programming questions.

Technical discussions are encouraged, but click here to ask your programming question.

The Lounge is rated PG. If you're about to post something you wouldn't want your kid sister to read then don't post it. No flame wars, no abusive conduct, no programming questions and please don't post ads.

AnswerRe: goto... Who uses it? PinmemberYvesDaoust3-Mar-13 22:31 
GeneralRe: goto... Who uses it? PinmemberFred Flams3-Mar-13 22:54 
AnswerRe: goto... Who uses it? PinmemberTieske83-Mar-13 23:08 
AnswerRe: goto... Who uses it? PinmemberSuper Lloyd3-Mar-13 23:43 
I am not afraid to say I used it at least 4 or 5 times! (in the last 10 years!...)
Even once recently!
I hate the mindless peer pressure against it, use it even it's ugly if you like!
Use whatever makes your code more beautiful! ^^
Just so you know, the (mindless violent) hate against it is based on the following argument: "it's not maintainable" i.e. "it break the flow of the code which should be otherwise obvious"
That much is true, long methods with goto label hidden 300 line below are big traps. But this is true of 300 lines method without goto too!!!
So, shortly, use it if it's the shorter more expressive solution. If someone doesn't like it, suggest them to fix the code. And choose the most expressive readable code between theirs and yours after that! Poke tongue | ;-P

Anyway, when one use goto?
Err... truthfully only one C# exemple comes to my mind (apart switch):
how to break out simple of multiple nest loop
for ()
          goto exit_loop;

Just so you know, a typical C goto will be for clean up, as in
if (success1) {...}
else goto failure
If (sucess2) { ...}
goto failure
but in C# this is more nicely expressed with try {} catch {} finally {} which doesn't need any goto
My programming get away... The Blog...
DirectX for WinRT/C# since 2013!
Taking over the world since 1371!

GeneralRe: goto... Who uses it? PinmemberAl Chak4-Mar-13 5:44 
AnswerRe: goto... Who uses it? [modified] PinmemberRob Grainger4-Mar-13 0:20 
AnswerRe: rarely but sometimes it's the solution [example inside] PinmemberJcmorin4-Mar-13 2:46 
GeneralRe: rarely but sometimes it's the solution [example inside] Pinmembertom14434-Mar-13 3:37 
GeneralRe: rarely but sometimes it's the solution [example inside] PinmemberJoe Woodbury4-Mar-13 5:13 
GeneralRe: rarely but sometimes it's the solution [example inside] PinmemberJcmorin4-Jun-13 6:47 

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

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

Advertise | Privacy | Mobile
Web04 | 2.8.150326.1 | Last Updated 27 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid