740
ifn't (programming.dev)
you are viewing a single comment's thread
view the rest of the comments
[-] 0x0@lemmy.dbzer0.com 200 points 2 years ago

I propose a new, more threatening kind of control flow.

do {
  /* something */
} or else {
  /* you don't want to find out */
}
[-] gex@lemmy.world 57 points 2 years ago

Some C++ style guides suggest the following naming convention for functions that crash on any error

OpenFileOrDie()
[-] xmunk@sh.itjust.works 25 points 2 years ago

PHP has the always wonderful (and perfectly functional) syntax of

logUserIn() or die();

[-] msage@programming.dev 6 points 2 years ago
[-] frezik@midwest.social 10 points 2 years ago* (last edited 2 years ago)

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 the t() function on the ifn 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.

[-] evatronic@lemm.ee 3 points 2 years ago

Where do you think PHP stole it from?

[-] Kissaki@programming.dev 9 points 2 years ago

Personally, I like to call catched exception variables up, so for a rethrow I can throw up;.

[-] TwilightKiddy@programming.dev 2 points 2 years ago

Except rethrowing an exception in C# is just throw;, anything else is a crime against the person who reads your stacktraces.

[-] OpenStars@startrek.website 4 points 2 years ago

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)

[-] MonkderZweite@feddit.ch 4 points 2 years ago

I mean, it makes sense to call ComplainToErrorAndExit just 'die', no?

[-] Vorthas@programming.dev 4 points 2 years ago

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.

[-] yum13241@lemm.ee 1 points 2 years ago

Now what about GZDoom's GoAwayAndDie();?

[-] Strawberry 38 points 2 years ago

this is just a menacing try/catch!

[-] moody@lemmings.world 21 points 2 years ago

It_would_be_a_shame_if(condition)

[-] Mesa@programming.dev 8 points 2 years ago

The better try-catch. More intuitive if you ask me.

[-] OpenStars@startrek.website 7 points 2 years ago

You just made me a offer I can't refuse. I go now to sleep with the fishes...

[-] jadelord@discuss.tchncs.de 7 points 2 years ago

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.

[-] rothaine@beehaw.org 5 points 2 years ago
do {
  /* something */
} do hast {
  /* something */
}
[-] 0x0@lemmy.dbzer0.com 7 points 2 years ago
do {
  /* something */
} do hast {
  /* something */
} do hast mich {
  /* something */
}
this post was submitted on 18 Jan 2024
740 points (100.0% liked)

Programmer Humor

25377 readers
1622 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS