|
For some reason, that just popped into my head.......I wasn't even looking at anything code related, was watching the "Couch Commander" video
Anyway, the question is are there any other "statements" such as the one in the subject' in any other programming language that so eloquently and succinctly tell you exactly what it's doing.......? The more obscure the language the better.
And if anyone says this is a programming question, which it is, but it's not, will get a skelped dock!
|
|
|
|
|
ERROR_SUCCESS
Not so much a statement, but a wonderfully descriptive return value.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
PLEASE NO!!
Don't ever utter tha line ever agian, make it forgotten from the whole world. The damages and catastrophes caused by that line are uncountable!
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|
|
Like catch (Exception) {} ?
I pretty much like my catches, so I'll keep using those thank you
If I couldn't use lines of code, functions, or libraries whose usage has made me cringe in the past I should really find another job. I've seen things
|
|
|
|
|
It dones't mean they don't have to be used - I use this one too (Yes, I still work with VB6) - but it would be way better to forget them at all.
The problems caused by those lines after years they have been developed... basically unfindable bugs because the sucker acts like there is no problem at all. Add this to the fact that the runtimes throws exceptions like candies instead of returning a status value and you have to manage exceptions for perfectly reasonable beahviours, like opening a non existing file. It can happen, it's usually no big deRUNTIME ERROR! CLOSE THE HATCHES! PREPARE FOR IMMERSION NOW!!!
So many times you simply stick to On Error Resume Next and then problems arise, after years of seemingly fine running. It's like having a bazooka for home defence. Effective it is, useful also, but it's farking dangerous.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|
|
Most TrySomething (like TryParse) methods swallow exceptions if you don't check for the return value.
The if-statement can be just as harmful. Take those huge nested if-else branches. Impossible to test, impossible to change (without breaking everything).
So we replace the if-statements with switch/case-statements, same thing happens.
We need to loop through some collection, but it's kind of recursive, and now some programmer uses foreach foreach foreach... (yeah, I've seen it happen).
In SQL Server when an exception occurs it's more or less swallowed UNLESS you use try-catch (how many programmers know that?).
So I now shouldn't use catch, TryParse, if, switch/case, foreach, and SQL Server
Well, I agree ON ERROR RESUME NEXT is the most useless of them all
|
|
|
|
|
You're absolutely right about the huge nested ifs, I usually tend to modularize a lot and where multiple checks are involved I use a SEQUENCE of if and a cumulative status, so that it becomes
bool keep_going = true;
if (error_cond1) keep_going = false;
if (keep_going && error_cond2) keep_going = false;
...
It's easier to read and modify, also it's not mandatory to have a single cumulative status. Since I work with stdcalls, VB6 and plain old C code on old compilers (long story short: we can't change.) I can't reliably use exceptions outside the deepest functions and being the VS6 stdlib what it is I don't really need them since it's better to stick to CRT functions, which don't have exceptions. Being VS6 CRT what it is many "safe" functions that use SEH exceptions do not exist so I don't use them either.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|
|
I think you could also put in a "goto" instead of setting "keep_going" if you want to break up that nested if architecture. 
|
|
|
|
|
If your code is something like this
try {
statement
} catch () {}
try {
statement
} catch () {}
...
Then the ON ERROR RESUME NEXT statement makes sense. I actually use it on occasion where I have a short procedure and I want the errors to be consumed and don't care what they are. Doesn't happen often but it does every now and then.
|
|
|
|
|
I think you need
catch (void) {} At least in C++ you can throw any type, not just derivations of
class Exception
|
|
|
|
|
|
MOVE CORRESPONDING
Still waiting for one of the "modern languages" to implement that one.
(I have to resort to reflection in C#).
|
|
|
|
|
Best line ever.
I think every language should have something like 'On Error Resume Next'. Once I added it, my program stopped crashing entirely! It's like magic! Imagine if we could just apply this to every application worldwide... No more software bugs!
(Before you start screaming, note the joke icon... Seriously... I'm crazy, but I'm not an idiot)
|
|
|
|
|
You'd have to go a long way to beat the eloquence of this:
$HODOR: hhodor? Hodor!? Hodor!? oHooodorrhodor orHodor!? d = HoDoRHoDoR () {
hodor.hod('Hhodor? Hodor!? Hodor!? o HODOR!? orHodor!? d!');
};
hhodor? Hodor!? Hodor!? oHooodorrhodor orHodor!? d();
Hodor Programming Language[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I would go a long way.............to beat the persons who come up with that!
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Richard Deeming wrote: Hodor Programming Language[^] That would be funnier if it didn't look almost exactly like a lot of the Java code I've had to manage.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
The modern version;
catch
{
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Not quite - the modern version would require wrapping every single statement in its own "Pokémon exception-handling" block.
Which would mean splitting all variable declarations from their assignments, since a variable declared inside a try block can't be used outside of that block.
Which would also mean giving every variable some sort of default value, either when they're declared, or in the empty catch block for the first line that assigns them.
And don't forget to update the properties of the global Err object, in case the user gave any thought to checking for errors on the following line, and didn't just let their code trundle on regardless and destroy the program state / database / computer / world.
Having worked with VBScript many years ago, where this was the only form of error handling allowed, it's an horrendous construct. Whoever came up with the idea deserves a good beating with the clue-bat.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Whoever came up with the idea deserves a good beating with the clue-bat. Probably someone who got paid per LOC.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You hold 'im, I'll hit 'im.
Then we can swap places. Repeatedly.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Richard Deeming wrote: he modern version would require wrapping every single statement in its own "Pokémon exception-handling" block.
Which would mean splitting all variable declarations from their assignments, since a variable declared inside a try block can't be used outside of that block.
Which would also mean giving every variable some sort of default value, either when they're declared, or in the empty catch block for the first line that assigns them.
And don't forget to update the properties of the global Err object, in case the user gave any thought to checking for errors on the following line, and didn't just let their code trundle on regardless and destroy the program state / database / computer / world Ah!
Now I understand why you love VB so much!
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
That's more like ON ERROR BAIL.
Steve
|
|
|
|
|
|
You've discovered infinite recursion
Remain Calm & Continue To Google
|
|
|
|
|
"IF THEN MAYBE", "DO SOMETHING" and "GO SOMEWHERE" have always had a special place in my heart....
MAYBEBOL
|
|
|
|