Click here to Skip to main content
15,891,777 members

The Insider News

   

The Insider News is for breaking IT and Software development news. Post your news, your alerts and your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be removed. If you wish to ask a programming question please post it here.

Get The Daily Insider direct to your mailbox every day. Subscribe now!

 
AnswerRe: Who is shane? Pin
Kent Sharkey12-Mar-14 8:02
staffKent Sharkey12-Mar-14 8:02 
GeneralRe: Who is shane? Pin
Rob Grainger12-Mar-14 23:39
Rob Grainger12-Mar-14 23:39 
GeneralRe: Who is shane? Pin
Kent Sharkey13-Mar-14 8:17
staffKent Sharkey13-Mar-14 8:17 
NewsIs goto still considered harmful? Pin
Kent Sharkey11-Mar-14 14:44
staffKent Sharkey11-Mar-14 14:44 
GeneralRe: Is goto still considered harmful? Pin
Ron Anders11-Mar-14 17:14
Ron Anders11-Mar-14 17:14 
GeneralRe: Is goto still considered harmful? Pin
Dennis E White11-Mar-14 17:16
professionalDennis E White11-Mar-14 17:16 
GeneralRe: Is goto still considered harmful? Pin
Member 1023287211-Mar-14 19:17
Member 1023287211-Mar-14 19:17 
GeneralRe: Is goto still considered harmful? Pin
irneb11-Mar-14 20:25
irneb11-Mar-14 20:25 
Member 10232872 wrote:
Can somebody explain this topic?
Yep, goto is in C ... and that code is actually using it. If you want an explanation, then there are numerous examples where goto "can" make your code go haywire ... IF you don't keep your wits about you and your code is rather complex.

IMO goto is OK for very simplistic stuff, like the sample in the article. But chances are that an inadvertent double copy-paste (like I'm sure happened in that bug) wouldn't cause a compiler error.

And that's the main reason goto is dangerous. It's much easier writing something in goto which makes no sense - while the compiler would still happily keep on compiling it. In more structured statements the chance is reduced (note not removed) that the compiler will fail to catch such inadvertent mistakes.

I think about the "avoidance of goto" as a form of safety measure I use against my own stupidity and/or tiredness.

For the article's sample I'd have gone for a single if with the options or'ed together, and the fail portion inside the if's then clause (IMO easier to comprehend and more succinct). It would probably compile to the same machine code anyway.

OR Roll eyes | :rolleyes: (can't say for sure since a lot of the code was removed for that article) I might even think about using something like a hash-set (seeing as all the checks are for equality), though only if the number of comparisons becomes huge. It would be easier to extend later if there's a new type of error code (even at runtime), and for large quantities of such comparisons it might even be more optimal - but most probably it would be overkill for this example.
GeneralRe: Is goto still considered harmful? Pin
Rob Grainger12-Mar-14 1:07
Rob Grainger12-Mar-14 1:07 
GeneralRe: Is goto still considered harmful? Pin
TheGreatAndPowerfulOz11-Mar-14 19:15
TheGreatAndPowerfulOz11-Mar-14 19:15 
GeneralRe: Is goto still considered harmful? Pin
Bassam Abdul-Baki12-Mar-14 3:26
professionalBassam Abdul-Baki12-Mar-14 3:26 
GeneralRe: Is goto still considered harmful? Pin
harold aptroot12-Mar-14 3:46
harold aptroot12-Mar-14 3:46 
GeneralRe: Is goto still considered harmful? Pin
Bassam Abdul-Baki12-Mar-14 3:58
professionalBassam Abdul-Baki12-Mar-14 3:58 
GeneralRe: Is goto still considered harmful? Pin
Dan Neely12-Mar-14 3:47
Dan Neely12-Mar-14 3:47 
GeneralRe: Is goto still considered harmful? Pin
Bassam Abdul-Baki12-Mar-14 4:00
professionalBassam Abdul-Baki12-Mar-14 4:00 
GeneralRe: Is goto still considered harmful? Pin
mikepwilson12-Mar-14 9:49
mikepwilson12-Mar-14 9:49 
GeneralRe: Is goto still considered harmful? Pin
Eddy Vluggen12-Mar-14 9:58
professionalEddy Vluggen12-Mar-14 9:58 
GeneralRe: Is goto still considered harmful? Pin
Richard Andrew x6412-Mar-14 15:54
professionalRichard Andrew x6412-Mar-14 15:54 
GeneralRe: Is goto still considered harmful? Pin
Rob Grainger12-Mar-14 23:42
Rob Grainger12-Mar-14 23:42 
GeneralRe: Is goto still considered harmful? Pin
Eddy Vluggen13-Mar-14 1:30
professionalEddy Vluggen13-Mar-14 1:30 
GeneralRe: Is goto still considered harmful? Pin
Rob Grainger13-Mar-14 3:12
Rob Grainger13-Mar-14 3:12 
GeneralRe: Is goto still considered harmful? Pin
Eddy Vluggen13-Mar-14 6:08
professionalEddy Vluggen13-Mar-14 6:08 
NewsTim Berners-Lee: 25 years on, the Web still needs work (Q&A) Pin
Kent Sharkey11-Mar-14 14:42
staffKent Sharkey11-Mar-14 14:42 
News5 predictions for the Web that were WAY off Pin
Kent Sharkey11-Mar-14 12:32
staffKent Sharkey11-Mar-14 12:32 
NewsValve open-sources its DirectX to OpenGL translation software: Here come the SteamOS and Linux games? Pin
Kent Sharkey11-Mar-14 12:14
staffKent Sharkey11-Mar-14 12:14 

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.