Goto (2007)
beej.us
Goto (2007)
1–10 of 207 posts
Re: Goto (2007)
#2Re: Goto (2007)
#3Re: Goto (2007)
#4Re: Goto (2007)
#5Re: Goto (2007)
#6Can't say that I'm enthusiastic about goto advice, but - for a second there, I thought the domain was bejeez.us :-P
Re: Goto (2007)
#7If there are multiple points of code failure that all require same cleanup procedure then one section at the bottom is acceptable and can actually keep the code cleaner.
Anything else looks like bad design that ends up producing hard to follow code.
Re: Goto (2007)
#8Re: Goto (2007)
#9Sometimes code with `goto` is simply easier to understand. You have to be careful, but dismissing it completely is throwing out a tool.
Re: Goto (2007)
#10Coming from assembly language, I always found the anti-goto sentiment rather cute. A beautiful restriction, but ultimately arbitrary. Like writing poetry. Or those novels that do not ever use the letter "e". Why would an otherwise sane person write code with "rep" and without ever using "jmp"?
The goal is to improve quality by making the code better structured and easier to follow.
For instance, MISRA C rule 15.1 that states that goto should not be used explains: "Unconstrained use of goto can lead to programs that are unstructured and extremely difficult to understand". Indeed, in practice that's often the case.