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.
Seen it; rewrote it. In (pre-Visual) BASIC code (ON ERROR GOTOs that would branch to different line labels depending on the ERRNO thrown) for nuclear weapons effects. Guess it's fitting, in retrospect, that "bomb code" worked by "blowing up"
That's an interesting coincidence. At the same job where I used that horrendous library the company built robots. They used Microsoft's BASIC as the embedded language and it had that ON ERROR stuff in it. It could get very tricky and downright dangerous when an emergency stop was activated because there was no telling where the robot would go next when the stop was cleared.
"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?"
Now that you wrote it, I see why it is obvious. I didn't think about it that much when I posted. To me it just made better sense when coding probably because of the lesser/better indentation.
Also it really pays off when the code is called recursively.
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
If you prefer to compare a logical expression to a logical constant (true, false), then I beg to disagree!
Do you ask someone: Is it true that you want a cup of coffee? Or do you ask: Do you want a cup of coffee?
You reserve the "Is is true that" form to very special cases, like: Is is true that you love me?
So "== true" or "== false" is completely banned from any code that I handle!
From my "programming childhood" I was brought up to write every funcition as a (1) verify all arguments and preconditions, (2) do the work, (3) prepare the results.
If in step 1 any precondition is not satisfied, then you prepare an error return and get out of there, making no changes. Don't even look at the work and result stages.
If anything in step 2 prevents you from creating a complete result, then you prepare an error return and get out of there, without any side effects or other kinds of results.
In step 3, with all preconditons met and all work successfully completed, you do whatever possible to preserve the results (e.g. wait for locks to be released). If all functions are written in this orderly manner, you very rarely run into problems in this step.
These "Get out of there" tests are usually semantically negative, even though they may be syntactically positive ("if (parameter outside legal range) ..."). The essential part is: Don't bother the clean work with debris (I count "n" levels of extra indentation due to validity checks as "debris"!). If there is nothing more you can do, then leave!
Any test that ends up in an abort/termination is placed as early as possible - and then there is no "else" and no extra indentation.
Within step 2, and sometimes even in step 1, the "if" selects one of two equally valid actions, or they are elseif-alternatives. In such cases, I write the test so that the most likely case comes first (even when that requieres negation of the logical expression). An elseif-sequence is ordered in decreasing likelyhood. The final else is the least likely one - like a default at the end of a switch case statement.