▲ 764 ▼ ifn't (programming.dev) submitted 2 years ago by JPDev@programming.dev to c/programmer_humor@programming.dev 127 comments fedilink hide all child comments
[–] gex@lemmy.world 59 points 2 years ago (11 children) Some C++ style guides suggest the following naming convention for functions that crash on any error OpenFileOrDie() permalink fedilink source parent hideshow 11 child comments replies: [–] xmunk@sh.itjust.works 26 points 2 years ago (4 children) PHP has the always wonderful (and perfectly functional) syntax of logUserIn() or die(); permalink fedilink source parent hideshow 4 child comments replies: [–] msage@programming.dev 6 points 2 years ago (3 children) Or Perl permalink fedilink source parent hideshow 3 child comments replies: [–] frezik@midwest.social 10 points 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. permalink fedilink source parent [–] evatronic@lemm.ee 3 points 2 years ago (1 child) Where do you think PHP stole it from? permalink fedilink source parent hideshow 1 child comment replies: [–] msage@programming.dev 2 points 2 years ago Bash? permalink fedilink source parent [–] Kissaki@programming.dev 10 points 2 years ago (1 child) Personally, I like to call catched exception variables up, so for a rethrow I can throw up;. permalink fedilink source parent hideshow 1 child comment replies: [–] 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. permalink fedilink source parent [–] MonkderZweite@feddit.ch 4 points 2 years ago I mean, it makes sense to call ComplainToErrorAndExit just 'die', no? permalink fedilink source parent [–] 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. permalink fedilink source parent [–] OpenStars@startrek.website 3 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) permalink fedilink source parent [–] yum13241@lemm.ee 1 point 2 years ago Now what about GZDoom's GoAwayAndDie();? permalink fedilink source parent
[–] xmunk@sh.itjust.works 26 points 2 years ago (4 children) PHP has the always wonderful (and perfectly functional) syntax of logUserIn() or die(); permalink fedilink source parent hideshow 4 child comments replies: [–] msage@programming.dev 6 points 2 years ago (3 children) Or Perl permalink fedilink source parent hideshow 3 child comments replies: [–] frezik@midwest.social 10 points 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. permalink fedilink source parent [–] evatronic@lemm.ee 3 points 2 years ago (1 child) Where do you think PHP stole it from? permalink fedilink source parent hideshow 1 child comment replies: [–] msage@programming.dev 2 points 2 years ago Bash? permalink fedilink source parent
[–] msage@programming.dev 6 points 2 years ago (3 children) Or Perl permalink fedilink source parent hideshow 3 child comments replies: [–] frezik@midwest.social 10 points 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. permalink fedilink source parent [–] evatronic@lemm.ee 3 points 2 years ago (1 child) Where do you think PHP stole it from? permalink fedilink source parent hideshow 1 child comment replies: [–] msage@programming.dev 2 points 2 years ago Bash? permalink fedilink source parent
[–] frezik@midwest.social 10 points 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. permalink fedilink source parent
[–] evatronic@lemm.ee 3 points 2 years ago (1 child) Where do you think PHP stole it from? permalink fedilink source parent hideshow 1 child comment replies: [–] msage@programming.dev 2 points 2 years ago Bash? permalink fedilink source parent
[–] Kissaki@programming.dev 10 points 2 years ago (1 child) Personally, I like to call catched exception variables up, so for a rethrow I can throw up;. permalink fedilink source parent hideshow 1 child comment replies: [–] 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. permalink fedilink source parent
[–] 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. permalink fedilink source parent
[–] MonkderZweite@feddit.ch 4 points 2 years ago I mean, it makes sense to call ComplainToErrorAndExit just 'die', no? permalink fedilink source parent
[–] 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. permalink fedilink source parent
[–] OpenStars@startrek.website 3 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) permalink fedilink source parent
[–] yum13241@lemm.ee 1 point 2 years ago Now what about GZDoom's GoAwayAndDie();? permalink fedilink source parent