Do you use the goto command?

NathanE said:
That's the first time you've made this point actually. It's a good point except that I doubt many people these days deal with languages which don't have high level constructs...

What about embedded systems? Command and Control systems? Weapons systems? Would you really want a cruise missile to be guided by something that runs with a VM?

Ada? Did I read that right? Ada? :eek: Are you an academic or something? :D

http://www.seas.gwu.edu/~mfeldman/ada-project-summary.html

Nope, no significant uses there....;)
 
NathanE said:
I highly doubt the average viewing populace of this forum write embedded software Visage.

I agree, but why does that matter?

A skilled developer is one that utilises the platform available to him/her to get the job done as well as possible. That is as applicable to embedded development on 8 bit processors as it is to writing the latest and greatest most flashy website.

Nothing I have written about GOTO's contradicts this; they can be useful in some contexts, and a dogmatic ban on them is nearly always inappropriate.
 
NathanE said:
But meh, it's all down to choice isn't it. I don't think either method is wrong and to be honest I might reconsider using GOTO in the nested loop scenario the next time it comes along.

"Oh look it's NathanE, the one who ****ed me off one time about tabs vs spaces, let's start an argument even though he holds mostly the same view as me!"
 
Last edited:
matja said:
longjmp is more fun. thats a MANS goto.

Nah - real men write pointers to files and then use them as future pointers to non-existence functions.

Security through obfuscation - its the future.
 
NathanE said:
"Oh look it's NathanE, the one who ****ed me off one time about tabs vs spaces, let's start an argument even though he holds mostly the same view as me!"

Was that directed at me? It gets somewhat confusing when you start quoting yourself and then responding.

Or has your inner monologue failed?
 
matja said:
I use goto (C/C++) where it can improve either the clarity or the performance of the code, whichever is more important at the time. To the people who have blindly taken Dijkstra's blessings to heart, I suggest that you become familiar with the other side of the argument - ie, Donald Knuth's paper - "Structured Programming with go to Statements", for examples where goto's are better in many ways than traditional inflexible structured programming practices.

This is how I feel as well, for example using goto to break out of multiple nested loops is pretty useful.

NathanE said:
Ada? Did I read that right? Ada? :eek: Are you an academic or something? :D

Ada is very heavily used in the defence industry - A hell of a lot of their systems are written in it.
 
Last edited:
For me, in older languages like Basic goto is an invaluable part of the language, but in modern languages like Java and C++ there should never be a need to use a goto.
I agree that they are useful when you are deep inside of a nested loop but some simple reformatting can remove the need for it, one way which has been mentioned already is to pass a flag into each loop and add a condition that checks the value of that flag. This will be optimized by the compiler but looks messy and can be difficult to maintain.
Another way is to use recursive functions, each part of the loop is a method that returns a boolean, it looks nicer and is easier to maintain but does essentially the same job.
 
MrSeanKon said:
:D the break statement is a variation of goto IMHO.
It is, but with break or continue you'll end up at a well-defined point in the execution of your program. Goto can land you anywhere you like. I've seen gotos that land you in the middle of switch statements, and although that particular example did work, it was mind-bending to get your head around. Generally if you have to resort to something like that, it means you should really be considering refactoring your code.

The problem with goto is that while it's useful in certain circumstances, it needs to be used *very* carefully. It tends to get abused because it's convenient.

(I'm an embedded software engineer for what it's worth)
 
Just finished my AS D&T (Systems & Control) project - I built an alarm clock. I used a PICAXE 18X - which has 2kB of program memory. I wrote the program in BASIC so there were no high level constructs available and I was using goto a lot. So yes, I do use goto.

Working with 2kB is great fun, shame I had to cut a few features to fit it all in.

null :)
 
null said:
Just finished my AS D&T (Systems & Control) project - I built an alarm clock. I used a PICAXE 18X - which has 2kB of program memory. I wrote the program in BASIC so there were no high level constructs available and I was using goto a lot. So yes, I do use goto.

Working with 2kB is great fun, shame I had to cut a few features to fit it all in.

null :)

2k? You young people dont know you're born....back in my day we used to dream of 2k of memory....
 
MrSeanKon said:
:D the break statement is a variation of goto IMHO.
No it isn't. Break is a structured programming construct whereas Goto isn't :~) Of course internally they may be implemented in similar ways (i.e. use the same instruction) but there are also plenty of other instances where a compiler will generate JMP instructions...

Visage said:
Was that directed at me? It gets somewhat confusing when you start quoting yourself and then responding.

Or has your inner monologue failed?
RTFT in future and you won't get so confused nor will you see the need to start petty arguments with random people.
 
Last edited:
NathanE said:
No it isn't. Break is a structured programming construct whereas Goto isn't :~)

Based on whose definition of structured programming, Dijkstra's? - 'break' doesn't strictly fit into _his_ paradigm of hierarchical program flow based on concatenation, selection and repetition structures (Dijkstra calls this the loop-and-a-half problem)
 
Wiggis said:
This will be optimized by the compiler but looks messy and can be difficult to maintain.

Optimized, but not elimitated to the degree that using a goto would have. (In my testing of gcc 4.1.1 and visual studio 2005) Simple fact that a flag requires storage _somewhere_. Of course most people do not care about this degree of performance, nor should - or you would be writing your code in assembly and profiling all the time.
 
matja said:
Based on whose definition of structured programming, Dijkstra's? - 'break' doesn't strictly fit into _his_ paradigm of hierarchical program flow based on concatenation, selection and repetition structures (Dijkstra calls this the loop-and-a-half problem)
I wasn't really referring to any specific form of structured programming. Just that I doubt there are many that include "Goto" in them :p:)

Visage said:
Pram tipped over, toys everywhere.....
If you say so :~)
 
matja said:
Optimized, but not elimitated to the degree that using a goto would have. (In my testing of gcc 4.1.1 and visual studio 2005) Simple fact that a flag requires storage _somewhere_. Of course most people do not care about this degree of performance, nor should - or you would be writing your code in assembly and profiling all the time.

Indeed. The dogmatic 'Thou shalt not use GOTOs' is nearly always inappropriate. Dogma has no place in software development.
 
Back
Top Bottom