Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Should I use carp/croak or warn/die

by jeffenstein (Hermit)
on May 30, 2018 at 16:45 UTC ( [id://1215482]=note: print w/replies, xml ) Need Help??


in reply to Re: Should I use carp/croak or warn/die
in thread Should I use carp/croak or warn/die

I'm guessing it's an Americanism. Sorry about that to the rest of the world ;)

"Carping" is slang for complaining about something. ex: He was carping about the wait for a table. "Croaking" is slang for dying. ex: Your pet fish croaked last night

They were rare in my youth, and outside of Perl, I haven't heard them used in probably 30 years.

Update: Just for kicks, here are some synonyms for "carp" from the Merriam-Webster dictionary: bellyache, bleat, caterwaul, croak, fuss, gripe, grouse, nag, whine, and whinge. It could have been worse.

  • Comment on Re^2: Should I use carp/croak or warn/die

Replies are listed 'Best First'.
Re^3: Should I use carp/croak or warn/die
by RonW (Parson) on May 30, 2018 at 22:06 UTC

    Actually, "carp", used as a verb, meaning complain, has been in use since the 1500s, so is long past the slang stage.

    However, "croak" is still considered a slang term.

Re^3: Should I use carp/croak or warn/die
by LanX (Saint) on May 30, 2018 at 17:09 UTC
    Well yes, I can construct mnemonics, German and English being very similar helps.

    But still I'm confused about the need to have several names for things which are almost similar - i.e. different only in orthogonal dimensions - instead of parametrizing them.

    Thanks anyway! =)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      I agree that PHPisms like 500 extra, semi-overlapping keywords can be a bad thing but I've always liked Carp's interface. Taking the generalized and parameterized route to extremes is warn and die becoming replaced with error($level, $message) or something. I use Carp's functions enough, including longmess and shortmess for logs, that I much prefer having specific functions for acking around and such.

        I'm fine with Huffman* coding keywords (often used = own keyword) and naming functions is indeed difficult ...

        But I'm still not happy, sorry ! :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

        update

        PS: any need to explain MilliHuffman? ;-)

      I can only guess why Larry & Co. did it this way, and that guess would be that it was to preserve backwards-compatibility with perl 4, which already had the current interface for warn and die.

      Did caller exist in perl 4? It kind of makes sense to use a different interface since modules got a lot of changes in 5.0

        Did caller exist in perl 4?

        According to http://www.rexswain.com/perl4.html, caller existed in Perl 4, and so did die and warn.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        From the perl.n manpage of perl 4 patchlevel 36:

        caller(EXPR)

        caller Returns the context of the current subroutine call:
        ($package,$filename,$line) = caller;
        With EXPR, returns some extra information that the debugger uses to print a stack trace. The value of EXPR indicates how many call frames to go back before the current one.
        perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1215482]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2024-04-25 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found