MrSeanKon said:OK the Fortran programmers of course yes!![]()
But the others (C, Basic) etc....
IMHO it is useful sometimes. Anyway what's your opinion?
I don't see how a JMP (a.k.a. "goto") instruction can ever improve performance as the processor can never predict it...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.
NathanE said:I don't see how a JMP (a.k.a. "goto") instruction can ever improve performance as the processor can never predict it...![]()
Use the "break" statementVisage said:What about exiting from deep loops quickly?
NathanE said:... To exit from nested loops use a boolean flag and conditionals on the loop conditions.
NathanE said:I don't see how a JMP (a.k.a. "goto") instruction can ever improve performance as the processor can never predict it...
NathanE said:Use the "break" statementTo exit from nested loops use a boolean flag and conditionals on the loop conditions.
Yes and some languages don't have GOTO/JMPVisage said:Some languages dont have break statements, and some dont have booleans. Some dont even have loops![]()
I'm not so sure about it being 'free'. 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.matja said:or faster, a goto...
Actually, the branch target buffer logic in modern CPUs makes this case (static branch) the most optimal. On Intel Core 2, uop fusion makes static branches essentially free, unlike exiting from nested loops using various flags. But at the end of the day, whatever gets the job done in fewer bugs...
NathanE said:I'm not so sure about it being 'free'. 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.
NathanE said:Yes and some languages don't have GOTO/JMPJava for instance
![]()
Catchy little sayings like that work both ways ya' know![]()
So you are saying that every language has GOTO?Visage said:Incorrect
Have to up the ante when you're aboutHow very smug.
NathanE said:So you are saying that every language has GOTO?![]()
And it's one thing supporting it in the VM, but entirely another exposing it in the language itself...
Have to up the ante when you're about![]()
Erm when you said I was "incorrect"Visage said:No. I've bnever said that. If I have then presumably you are able to point out where I did so.
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...My original point was that GOTO's are sometimes necessary in languages that dont have some of the 'advanced' constructs that one commonly sees. It absence in a language such as Java is in no way indicative of its general utility.
Ada? Did I read that right? Ada?Ada, for example, has been developed specifically for mission, safety and security critical software since the early 80's, and yet it has a GOTO statement......
Whilst I like cheese, I'm not a mouse. You can't bait me that easilyBeing smug is fine, as long as one has something to be smug about.