The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
A lot of these prohibitions are in reality "almost never do such and such." But at the end of the day, other things being equal, it's all about clarity and readability and there will be cases where it's fine. The language directive does exist after all (when it does).
Years ago I recall reading a section in the book Code Complete by Steve McConnell where he presented some code using goto and stats showed that almost no developers were able to rewrite it correctly without the goto.
I was going to chime in that all Exception handling is really goto programming and then I saw DRHuff's excellent reply.
People talk about never using goto and then you look at their code and see exception handling and think, "what's this here?"
This is also why exception handling can be a pain in the arse. All that jumping around.
Consider what happens if you throw an exception in your catch block -- and it is possible. Things can get really ugly jumping here, bouncing there.
I think the only time that exception handling should be used is when the current code section does not have any control over the code that is throwing the exception - i.e., it is preferable to check and control something than to rely on an exception that simply does a goto the catch branch.
I had the misfortune of having to deal with an automation systems framework that was essentially a state machine library and it changed states by throwing an exception. I thought it was incredibly stupid. This framework was spreading throughout one division of a customer until someone finally pulled their head out and asked what is this pile you have subjected us to?
This particular customer joined my very short list of the worst ones I have ever dealt with and I refuse to buy any of their products to this day.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
agreed. I'm thinking of calls to another library where it throws a specific exception after being configured properly. In that case all inputs are set to valid values but then something happens which causes the exception - network not available or something.
And what happens when the language you are programing in offers no try-catch-throw?
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.
I don't know who you are. I don't know what you want, but I have a very particular lack of skills. I will never be able to find you. But what I do have is two dollars and a Casio wristwatch. You can have one of them.
it's an old view but as a Hardware/Firmware type I cannot see the hatred for goto, I mean the jmp is a direct map and it produces a smaller binary. Goto is like an axe very useful but very dangerous. An axe wont cut your hand off, misuse it and you could be missing a hand very easily!
Coming from a embedded back ground, GOTO maps directly to JMP! write assembly without JMP. Like you said I battled with object oriented code that is c*ap but well structured. I like anything don't blame the tools, blame the tool using the tool!