Click here to Skip to main content
11,480,938 members (60,980 online)

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? Pin
C-P-User-31-Mar-13 17:21
memberC-P-User-31-Mar-13 17:21 
GeneralRe: goto... Who uses it? Pin
Rob Grainger4-Mar-13 1:26
memberRob Grainger4-Mar-13 1:26 
GeneralRe: goto... Who uses it? Pin
C-P-User-34-Mar-13 4:39
memberC-P-User-34-Mar-13 4:39 
AnswerRe: goto... Who uses it? Pin
Member 46088981-Mar-13 22:27
memberMember 46088981-Mar-13 22:27 
AnswerRe: goto... Who uses it? Pin
YvesDaoust3-Mar-13 22:31
memberYvesDaoust3-Mar-13 22:31 
GeneralRe: goto... Who uses it? Pin
Fred Flams3-Mar-13 22:54
memberFred Flams3-Mar-13 22:54 
AnswerRe: goto... Who uses it? Pin
Tieske83-Mar-13 23:08
memberTieske83-Mar-13 23:08 
AnswerRe: goto... Who uses it? Pin
Super Lloyd3-Mar-13 23:43
memberSuper 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? Pin
Al Chak4-Mar-13 5:44
memberAl Chak4-Mar-13 5:44 
AnswerRe: goto... Who uses it? [modified] Pin
Rob Grainger4-Mar-13 0:20
memberRob Grainger4-Mar-13 0:20 
AnswerRe: rarely but sometimes it's the solution [example inside] Pin
Jcmorin4-Mar-13 2:46
memberJcmorin4-Mar-13 2:46 
GeneralRe: rarely but sometimes it's the solution [example inside] Pin
tom14434-Mar-13 3:37
membertom14434-Mar-13 3:37 
GeneralRe: rarely but sometimes it's the solution [example inside] Pin
Joe Woodbury4-Mar-13 5:13
memberJoe Woodbury4-Mar-13 5:13 
GeneralRe: rarely but sometimes it's the solution [example inside] Pin
Jcmorin4-Jun-13 6:47
memberJcmorin4-Jun-13 6:47 
AnswerRe: goto... Who uses it? Pin
César de Souza4-Mar-13 3:05
memberCésar de Souza4-Mar-13 3:05 
AnswerRe: goto... Who uses it? Pin
Gary Huck4-Mar-13 3:29
memberGary Huck4-Mar-13 3:29 
GeneralRe: goto... Who uses it? Pin
tom14434-Mar-13 3:40
membertom14434-Mar-13 3:40 
GeneralRe: goto... Who uses it? Pin
Gary Huck4-Mar-13 3:41
memberGary Huck4-Mar-13 3:41 
GeneralRe: goto... Who uses it? Pin
Joe Woodbury4-Mar-13 5:14
memberJoe Woodbury4-Mar-13 5:14 
GeneralRe: goto... Who uses it? Pin
tom14434-Mar-13 5:29
membertom14434-Mar-13 5:29 
GeneralRe: goto... Who uses it? Pin
Jcmorin4-Mar-13 4:03
memberJcmorin4-Mar-13 4:03 
GeneralRe: goto... Who uses it? Pin
Climate Turnip5-Mar-13 9:04
memberClimate Turnip5-Mar-13 9:04 
AnswerRe: goto... Who uses it? Pin
NAANsoft4-Mar-13 4:17
memberNAANsoft4-Mar-13 4:17 
AnswerGOTO - a useful tool in the right hands Pin
Chris Boss4-Mar-13 4:19
memberChris Boss4-Mar-13 4:19 
AnswerRe: goto... Who uses it? Pin
CDMTJX4-Mar-13 4:30
memberCDMTJX4-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.150520.1 | Last Updated 24 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid