I propose a new, more threatening kind of control flow.
do { /* something */ } or else { /* you don't want to find out */ }
It_would_be_a_shame_if(condition)
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.
do { /* something */ } do hast { /* something */ }
do { /* something */ } do hast { /* something */ } do hast mich { /* something */ }
The better try-catch. More intuitive if you ask me.
this is just a menacing try/catch!
Some C++ style guides suggest the following naming convention for functions that crash on any error
OpenFileOrDie()
PHP has the always wonderful (and perfectly functional) syntax of
logUserIn() or die();
Or Perl
Perl also has
unless()
for the very purpose in OP, which is a more sensible choice.Oh, and if you need to reinforce your belief that Perl is a mess, the single-quote character can be used as a package separator instead of “::”. This was set in the 90s when nobody was quite sure of the right syntax for package separators, so it borrowed “::” from C++ and the single quote from Ada (I think).
That means the
ifn't()
in OP can be interpreted as calling thet()
function on theifn
package.The “::” separator is vastly preferred, though. Single quotes run havoc on syntax highlighting text editors (since they can also be used for strings). About the only time I’ve seen it used is a joke module,
Acme::don't
.
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.
You just made me a offer I can’t refuse. I go now to sleep with the fishes…
Imagine the regex needed to highlight code with that extra single quote.
I’m struggling to understand if this is true or ifn’t true
Why not just ifnot? Same count of characters but an o instead of a possibly problematic single quote.
I think it’s just capitalizing on a trend to add n’t to otherwise noy contractions, to make them into contractions. Contractionn’ts, if you will
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'
?
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
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
And Perl
And my axe!
totally agree; just saying that if it’s GOT to be something, that something should probably be unless… unless . . .
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.
deleted by creator
This can’t be for real. I’ll stick with C11 thank you.
Here you dropped this:
#define ifnt(x) if (!(x))
“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
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”.
ifn't (myNum don't= 3 && myStr ain'tnull'rblankish)
I hate seeing colloquial terms like ‘ain’t’ in non-comment (ie. standardized) parts of code
Still not as good as
whence
Is this a reference to something because I’d love to read it if you have a time to share.
Woah. I did a quick google and it’s not just a meme, but actually used in some major lang’s libraries.
This is one of those “modern Google/search sucks” moments because I couldn’t immediately find examples of it in a programming language.
I actually used DDG and most I’ve seen, they’re just used as arguments for functions notably in C and Python
This has to be illegal. I mean, it’s basically suicide incitement (or whatever is the phrase for it)
I can actually define this in TCL:
% proc ifn't {cond cmds} {if {!$cond} {uplevel $cmds}} % ifn't false {puts 12} 12 % ifn't true {puts 12} %
This is the !biggest comp sci innovation in !decades
cap () {
}
nocap () {}
nocap(frfr){
}
die unless $keyword == “unless”;