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.
In high level languages... Ok, maybe you have more possibilities and you should avoid using goto's
But try to programm in Assembly, in PLC LAD or other similar "low" level languages without it.
It is like many other things. Use it wisely and there would be no problems. Abuse or misuse it... and you will burn in hell (or you will be damned and sent to hell by the people who inherit your code)
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
1. Create a workflow manager using generics, interfaces, class abstraction, enums for state and continuation.
2. Break up your code into small workflow steps.
3. On each step, check for termination.
4. Or to get really fancy, return a code that says what step in the workflow to skip to.
5. If you really want to be cool, allow for async workflow steps!
<snicker> I started coding in SuperBase, GOTO and GOSUB were standard and recommended constructs. Transitioning to VB in the 90's was no benefit. It was only when I started using c# that I abandoned them completely.
Some of us have shameful pasts.
Never underestimate the power of human stupidity -
I'm old. I know stuff - JSOP
These days the "goto" is back, I find this very unfortunate.
Every time someone writes a RETURN or a BREAK statement, he/she is actually writing a GOTO
And the worse thing about it is that this is encouraged these days...
The GOTO statement used to be pure evil. In BASIC it used to go to a line number. Not very easy to understand what it is intended to be doing at the best of times. Add in the fact that you could renumber every line in the program with the RENUMBER command and the GOTO statements would not update to reflect the line number changes and you have GOTO hell. (Not to mention that a lot of versions of BASIC at the time had missing features, for example procedures, functions, while loops, repeat loops.)
These days with the GOTO statement going to a label it has had it's teeth filed and, while not a common feature is nothing to be afraid of.
Code sample would be nice. Because honestly, with the amount of control structures and object orientation support it provides I don't see a reason to use it. In fact. I work with C# since I was 24 years old (I am 36 now). Never had to use goto since (except from a few side projects in C).
I used moro goto on imperative/structured/procedural languages like C, C++ and BASIC. So on purely objected oriented programming, whenever I thought of goto, it flashed a yellow light to me indicating I probably got some design patterns wrong. After some time I never got that yellow light again.
I am not saying your use is not justified, I just can't wrap my head around a reason to use it.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
Our heads are round so our thoughts can change direction - Francis Picabia
Use of GOTO is not always bad, nor a sign of poor design. Have a look at the Linux kernel source code sometime. You will see it littered with GOTOs everywhere. GOTO is an elemental part of their error-handling paradigm, they use it in a defined and regular way. The Linux kernel is not the only major and highly regarded software project to use this method, either, it just may be the most prominent.
But that said, a colleague of mine tried to employ the same paradigm to some of our own in-house code, and upper management pitched a hellacious fit when they got wind of somebody trying use GOTOs. A group of developers (very good ones) mounted a defense of it, but it was no use. Everybody flatly over-ruled, everybody shamed for having the thought.
Last Visit: 17-Aug-19 19:42 Last Update: 17-Aug-19 19:42