You are viewing a single thread.
View all comments View context
60 points

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

OpenFileOrDie()
permalink
report
parent
reply
27 points

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

logUserIn() or die();

permalink
report
parent
reply
6 points

Or Perl

permalink
report
parent
reply
2 points

Where do you think PHP stole it from?

permalink
report
parent
reply
10 points
*

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.

permalink
report
parent
reply
4 points

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

permalink
report
parent
reply
10 points

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

permalink
report
parent
reply
2 points

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

permalink
report
parent
reply
4 points

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.

permalink
report
parent
reply
3 points

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)

permalink
report
parent
reply
1 point

Now what about GZDoom’s GoAwayAndDie();?

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

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

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 5.2K

    Monthly active users

  • 1.1K

    Posts

  • 38K

    Comments