Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Yes, I am always using this, in my Assembly code.
@g-m-f nested for super break
I remember the only time I ever used a GOTO statement in a Pascal program and having someone give me some grief about it.
It was a compiler, and it was used to terminate the program if the input suddenly (unexpectedly) ended.
This idiot thought I should have threaded an extra parameter through every single function and procedure along with umpteen testing of that parameter after every call of every procedure and function - because that was more "structured".
Just terminate the program using a GOTO statement to unwind the stack and end cleanly.
I never used a single goto and I don't see a reason to ever use it
I'd use it cause it reminds me of a simpler time, a fun programming experience on my Amstrad CPC 464 and, later, my windows with DOS pcs. Ah, BASIC. The good old days.
goto should never be used
@theactionslacks That's it? That's your argument?
You think in the example I gave I should have polluted every procedure and function with an extra parameter that had to be constantly tested after every call?
All to be a purist?
I am with Ralph Waldo Emerson when he said " A foolish consistency is the hobgoblin of little minds".
@g-m-f It was the 1980s and No, there was no exception handling. Nothing wrong with the code, fairly straight-forward recursive descent parsing which is fine so long as the program it is compiling doesn't suddenly stop mid-statement.
In which case you unwind slowly and painfully with an extra parameter and umpteen tests, or you just GOTO a stop condition.
Those were the tools we had.
GOTO was clearly the most appropriate solution and incidentally is the only time I have ever used a GOTO statement outside of Assembler programming and my teenage years learning to program with Basic.
I still have the book "Structured Programming" by Dahl, Dijkstra and Hoare which I read around the same time that compiler was written.
I have no interest in dismissive statements like "GOTO should never be used" by people clearly not interested in understanding the context in which it is clearly appropriate.
@g-m-f from The C++ programming language 4th edition
@g-m-f I don't see how this is a good example. You can easily write the same code without goto. Also you will need an explicit return before the goto which looks kinda strange. Imo the goto just leads to worse code.
But I agree that in older languages there might be use cases for goto (although I don't see any).