I propose a new, more threatening kind of control flow.
do { /* something */ } or else { /* you don't want to find out */ }
Some C++ style guides suggest the following naming convention for functions that crash on any error
OpenFileOrDie()
Personally, I like to call catched exception variables
up
, so for a rethrow I canthrow up;
.Except rethrowing an exception in C# is just
throw;
, anything else is a crime against the person who reads your stacktraces.
One of the modules in a project I’m working on is called
VulkanOrDie
which always makes me crack up when I see it in the compilation messages.I mean, it makes sense to call ComplainToErrorAndExit just ‘die’, no?
It’s funnier when you try to SysCallAndDie() :-P
(that’s a real thing in perl btw - I guess that function didn’t get the memo)
Now what about GZDoom’s
GoAwayAndDie();
?
this is just a menacing try/catch!
It_would_be_a_shame_if(condition)
The better try-catch. More intuitive if you ask me.
It exists, kind of. Python has this construct
for item in iterable: ... else: ...
which always puzzles me, since it depends on a break statement execution. I always have to look it up when the else block is executed.
You just made me a offer I can’t refuse. I go now to sleep with the fishes…
do { /* something */ } do hast { /* something */ }
do { /* something */ } do hast { /* something */ } do hast mich { /* something */ }
Please God let this be a humorous post that somehow does not also find a way to manage to come true…
I would have bought it if they said ifnot instead, it’s the same number of characters and wouldn’t require a major parser overhaul to support keywords with a ’ in the name.
i mean, “unless” tends to be the usual term for an “if not” keyword in languages that implement such a thing
Which is awful and incredibly confusing. I hate ruby
totally agree; just saying that if it’s GOT to be something, that something should probably be unless… unless . . .
And Perl
And my axe!
I find that you need to choose carefully when to use it. Simple cases tend to be alright. Larger, more complex conditions shouldn’t touch it.
Yeah, to be clear, I don’t like it, I don’t like it one bit:-P.
If not anybody have time for that.
*ifn’t*
Oh dear Lord what have I done!? :-P
deleted by creator
cap () {
}
nocap () {}
nocap(frfr){
}
Reduce exclamation marks!? Great Scott!!! Is there a shortage of punctuation in the future!?
You could have saved two, all you had to do was use the interrobang. You’re a monster.
All known deposits were depleted
1.21GB!!!
Kernighan, what was I thinking?
deleted by creator
unlessn’t
I’m sorry, I hate the “unless” so much
At one of my first jobs, I was tasked to rewrite a bunch of legacy Perl scripts in Python and the unless lines always made me trip up. I don’t know why but it really messed with my mental flow when reading Perl code
Basic used “else”.
It’s nice. “if”, “then”, and “else”. I spent a year programming a shitty roulette game on an Apple 2e back in high school. I still remember the joy of using if/then/else paired with goto to make a horrible mess of spaghetti logic.
But yeah, “else” is nice.
Using a standalone ‘else’ would tickle my brain in the same nice way that being able to declare a variable inside an ‘if’ statement as if it were a ‘for’ loop (which you can do in modern C++) does.
Many languages let you scope variables.
In c# you can create an arbitrary scope to declare variables in. Most likely in others as well.
Ah clever, didn’t think of doing this. Not having to encapsulate if statements in scopes would still look cleaner though
It’s handy if you’re creating temp variables for single use that you don’t need to use again.
Although I admit I’ve only ever done it a couple times lol
Again in c# you can omit the scope and only the next statement is part of an if or loop.
Or a rust “if let”
Ooh yes. Rust is king when it comes to this sort of inline stuff. Inline
match
. Mmmmmm!
Block scoped variables are bad?
🤷♂️
Let’s just scrap every language except various forms of BASIC.
Please God, no. I had to unravel terminal scripting code that was written in some propriety BASIC language with basically no documentation.
Took me a chunk of time trying to figure out how it worked before I made the realization that it was BASIC
Try PL/SQL.
I haven’t written any Ruby for years, but I still praise it in every conversation I have regarding programming languages. It’s basically a much simpler Python, with some design ideas that are both beautiful and deeply strange.
Ruby was designed to evoke joy and they absolutely succeeded. Usually, programming is mostly a means to an end to me. But using Ruby just feels so amazing, it’s almost impossible to even describe to somebody who has never used it before.
The Perl version of it is even greater!
aint (something) { somethingElse() }
As a Virginian learning coding, this would make my damn day.
#define aint(x) if (!(x))
Or maybe
taint(condition) {}
Why not just ifnot? Same count of characters but an o instead of a possibly problematic single quote.
Yes… how is “reducing exclamation marks” a good thing when you do it by adding a
'
(not to be confused with,
´,
‘or
’` …which are all different characters).Does this rely on the assumption that everyone uses a US QWERTY keyboard where
!
happens to be slightly more inconvenient than typing'
?If someone really wanted to add it, probably the best would be to use
unless
I really liked having
unless
in Ruby; a!
can be easy to miss, whileunless
made it clear without needing to write out!= true
.It’s also cool when you do unless(!condition). I particularly like this.
ifn't(!valid)
halp?I believe that resolves the same as
ain’t!(!untrue)
Removed by mod
{ put(a, "heartache") tell(me, "why") ain't(nothing) { put(a, "mistake") //... } }
“Help’s with readability”? You know what else helps? Not using contractions and introducing an unbalanced single quote.
If they’d’nt’ve done that, it’d’ve been better. Agreed.
Aside: rip Tom Scott
TIHI
Runs havoc on parsing, too. It’s bad for both humans and robots. I say we ship it.
This feels racist against Appalachia. We naturally speak with contractions and are commonly referred to as “unbalanced”.
I’m struggling to understand if this is true or ifn’t true
I’m just hoping this paves the way to code with Southern dialect
iffun is == true iffun ain't == false
May I introduce you to the joys of #define and creating your own horrible sub language
That reminds me of an old paper about how to create a compilable C program out of old game ROMs. Decompile to assembly. Implement a bunch of
statements that implement all the ASM statements. Now compile it to a native binary on whatever platform.
Won’t likely be faster or more accurate than regular emulation methods, but it’s a neat idea considering that the source code on all this stuff was lost a long time ago.
I’d take a
not
or “if not” operator tbh.It has a not keyword it’s used for pattern matching.
if (x is not null)
It also has a
!=
.Pattern matching is different.
Yeah, I just said it since you used it with null. I used it a lot for enums
The type matching is the most common thing I use it with. Combined with inline variables.
if (x is string { Length: 5} s) { // do stuff with s }
And switch expressions.
As a side note inline variables are amazing haha
ifnt instead of ifn’t
ifn't (myNum don't= 3 && myStr ain'tnull'rblankish)
Please remain calm, we are sending paramedics to your location.
I genuinely lol’d
I hate seeing colloquial terms like ‘ain’t’ in non-comment (ie. standardized) parts of code
With ahit like that its not microsoft java its now microsoft javascript
That’s Typescript…
Ding ding ding ding ding ding…