this post was submitted on 18 Jan 2024
763 points (98.6% liked)

Programmer Humor

19659 readers
723 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 1 year ago
MODERATORS
763
ifn't (programming.dev)
submitted 10 months ago by JPDev to c/programmer_humor
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 59 points 10 months ago (6 children)

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

OpenFileOrDie()
[–] [email protected] 26 points 10 months ago (1 children)

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

logUserIn() or die();

[–] msage 6 points 10 months ago (2 children)
[–] [email protected] 10 points 10 months ago* (last edited 10 months 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.

[–] [email protected] 3 points 10 months ago (1 children)

Where do you think PHP stole it from?

[–] msage 2 points 10 months ago
[–] Kissaki 10 points 10 months ago (1 children)

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

[–] TwilightKiddy 2 points 9 months ago

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

[–] Vorthas 4 points 10 months 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.

[–] [email protected] 4 points 10 months ago

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

[–] [email protected] 3 points 10 months 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)

[–] [email protected] 1 points 10 months ago

Now what about GZDoom's GoAwayAndDie();?