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.
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 and please don't post ads.

Technical discussions are welcome, but if you need specific help please use the programming forums.


 
AnswerRe: goto... Who uses it? PinmemberC-P-User-31-Mar-13 17:21 
GeneralRe: goto... Who uses it? PinmemberRob Grainger4-Mar-13 1:26 
GeneralRe: goto... Who uses it? PinmemberC-P-User-34-Mar-13 4:39 
AnswerRe: goto... Who uses it? PinmemberMember 46088981-Mar-13 22:27 
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 ()
  for(..)
    for(..)
    {
       if(condition)
          goto exit_loop;
    }
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
...
return;
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 
AnswerRe: goto... Who uses it? PinmemberCésar de Souza4-Mar-13 3:05 
AnswerRe: goto... Who uses it? PinmemberGary Huck4-Mar-13 3:29 
GeneralRe: goto... Who uses it? Pinmembertom14434-Mar-13 3:40 
GeneralRe: goto... Who uses it? PinmemberGary Huck4-Mar-13 3:41 
GeneralRe: goto... Who uses it? PinmemberJoe Woodbury4-Mar-13 5:14 
GeneralRe: goto... Who uses it? Pinmembertom14434-Mar-13 5:29 
GeneralRe: goto... Who uses it? PinmemberJcmorin4-Mar-13 4:03 
GeneralRe: goto... Who uses it? PinmemberClimate Turnip5-Mar-13 9:04 
AnswerRe: goto... Who uses it? PinmemberNAANsoft4-Mar-13 4:17 
AnswerGOTO - a useful tool in the right hands PinmemberChris Boss4-Mar-13 4:19 
AnswerRe: goto... Who uses it? PinmemberCDMTJX4-Mar-13 4:30 

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
Web01 | 2.8.1411028.1 | Last Updated 29 Nov 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid