DEV Community

Discussion on: What are the great function/method/etc. names in popular libs/languages?

Collapse
 
hoelzro profile image
Rob Hoelz

Perl's Carp module has some interesting naming choices:

# warn user (from perspective of caller)
carp "string trimmed to 80 chars";

# die of errors (from perspective of caller)
croak "We're outta here!";

# die of errors with stack backtrace
confess "not implemented";

Not to mention that Perl introduces lexical variables with the my keyword, and package variables with the our keyword!

Collapse
 
shalvah profile image
Shalvah

confess 😂😂

Collapse
 
jakebman profile image
jakebman • Edited

And those were named to fit the model of die (exit, failing, with message)

Also Perl's or operator is intentionally lower precedence than almost anything else so you can:

my $file = open '/dev/zero' or die "Couldn't open file";

"OR DIE!"