|
You have the right to disagree, I'm saying this is a case where I see goto have it's usefulness.
Yes you can split into multiple function but sometimes there is 10+ parameters involved and creating subfunction doesn't make it clearer.
I respect your opinion and your strict mode but don't get me wrong... all languages [more or less] have the goto keyword or an equivalent.
|
|
|
|
|
It is often considered OK to call a goto from a deeply nested loop in order to terminate all loops altogether early, without the need of adding and maintaining several guard variables in the loop conditions. Of course if you can afford to place your loop in a separate function, you can also return from that, eliminating the goto but still doing the same.
|
|
|
|
|
Been writing code since '85. Never used a goto in production code and I would have serious issue[s] with anyone who did.
|
|
|
|
|
Good luck writing any assembly code without it.
|
|
|
|
|
Good luck getting me to write production assembly.
|
|
|
|
|
I wrote assembly for years and never used "goto". 
|
|
|
|
|
That is why I alias goto to JMP!
|
|
|
|
|
see my example the message above your.
If goto were that bad new language like C# would not have include it. It has a purpose, but it must be use in special case. Yes it can be avoided but something it the most clean solution.
|
|
|
|
|
Yes, quite.
So you would have serious issue[s] with the people who wrote:
jpeglib
libsoap
lua runtime
mongoose
gifencod
etc. (just the examples I have at hand).
Never had much of a problem maintaining/debugging a flow control that uses a label.
Switch statements have probably caused more problems.
But then I'm just being objective.
|
|
|
|
|
There is the "goto" in C# switch. That I have used lately.
Otherwise I regard break and continue as instances of goto: break is the good guy (forwarding) where continue is the bad guy (backwarding(!)).
/ Normann
|
|
|
|
|
GOTO is a vital tool for programmers wanting to develop high performance applications.
In my primary commercial product (a GUI engine used by other programmers) I use it over a dozen times.
Even the likes of Alexander Stepanov consider it useful, so I am in good company.
|
|
|
|
|
Its been beaten into me over the years not to use GOTO's.
Programming languages differ, but most have some sort of if / then / else that makes clearer programming than goto. Loops with leave / break statements, etc.. Even Fortran has these (I used it before it did)...
I find indenting with GOTO replacements clearer to follow than hunting for GOTO's and their destination. Esp if you have huge functions.
Even DOS batch scripting has if / then statements. Few years ago I cleaned up some messy batch scripts to make them readable...
|
|
|
|
|
The only place I can think where it might still be used in modern high-level languages is if one also adheres to the ancient (and out-dated?) principle that a function should have a single exit point. Sometimes making that happen without goto makes for some clunky, hard to read code with multi-level nests of IF blocks.
My sig will confirm that I agree with you, though I haven't used goto since I abandoned QuickBasic some 15 years ago, and haven't written assembly in 20+.
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
There is not an assembler program without GOTO.
Fortran without GOTO is too hard.
But in the real programming - GOTO is absolute unusable in all situations. Last 25 years, I did not write GOTO( expect assembler) and removed each one from reused code.
|
|
|
|
|
Twenty years ago i was 10, and learning to program in QBASIC. That was the last time I used GOTO.
|
|
|
|
|
I grew up with gotos, and saw their abuse first hand. Then some luminary someplace realized they were being abused, so decreed them to be evil. Now I keep them hidden away in my basement, away from prying eyes. I don't abuse my gotos like other programmers did, and see that they can still be useful, but I'm too scared of what the other programmers would say to let them out to frolic once in a while. Poor abused little gotos ;(
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
As a matter of fact, I have to MainTainTheInsane Ball of string of GoTo's in legacy applications that were written decades ago by someone who is long gone. I see it all over and really had a fit when I had to code around them. But since I have been learning COBOL of all flavors, I can now see that it was all they had back then; think of Sequential programing real hard with no bells and whistles like the modern languages have now. After figuring out what one of these old legacy apps does, I have to admire the person/s who had written them; they had to be a lot more creative with so little to work with than what programmers have today to work with. Actually, I have seen some really cool logic using the GoTo; and again, some really insane WTF! stuff. Back in the days, yeah, it was necessary. Todays programming, NOT 
|
|
|
|
|
I've used goto in C for coroutines in IP or serial protocols, mainly for manually crafting versions of the Protothread / Duffing machine trick. It's also handy in trampoline functions for tail recursion.
It can be clearer and more consise than the alternatives.
modified 4-Mar-13 12:54pm.
|
|
|
|
|
I can think of only one use for a Goto - tail recursion. A gosub or call immediately followed by a return can be replace by a Goto, saving stack space and the time needed to create/undo a stack frame.
|
|
|
|
|
Today is my daughters first birthday.
She's celebrating it with puking, pooping and sleeping on top of my chest with 40 degrees of fever. If I try to put her to bed she start whining.
I suppose this is bonding
"The ones who care enough to do it right care too much to compromise."
Matthew Faithfull
|
|
|
|
|
You have my sympathies, we had to cancel 3 of my sons first 4 birthday parties due to this. Hope she feels better soon.
|
|
|
|
|
I'm pretty calm about it. She's a fighter, and her overall condition is fine.
She also started her life with the flu. That was a very nervous week at the hospital
"The ones who care enough to do it right care too much to compromise."
Matthew Faithfull
|
|
|
|
|
Couldn't imagine that, I would have been out of my mind.
|
|
|
|
|
It was a bit taxing.
"The ones who care enough to do it right care too much to compromise."
Matthew Faithfull
|
|
|
|
|
jeron1 wrote:
You have my sympathies, we had to cancel 3 of my
sons due to this. Hope she feels better soon.
I think it’s more amusing that way.
There is only one Vera Farmiga and Salma Hayek is her prophet!
Advertise here – minimum three posts per day are guaranteed.
|
|
|
|