The stupid question is the question not asked | |
PerlMonks |
Re: unified warnings, good or bad?by Jenda (Abbot) |
on Nov 26, 2009 at 13:24 UTC ( [id://809560]=note: print w/replies, xml ) | Need Help?? |
There's one important difference between warn vs. carp and die vs. croak. The later is "from perspective of caller". Loosing the distinction would be fairly bad. If your subroutine complains about an invalid/missing parameter, it's pointless to tell the developer the position of the test, you want him to know the position of the call so you carp/croak. OTOH, if something goes crazy within the inner workings of the subroutine, it should warn/die. You can turn croak() to confess() and carp() to cluck() by "use Carp qw(verbose);" or by "perl -MCarp=verbose script.pl" and it would be nice to be able to control warn() and die() like this as well, but definitely not by turning them to confess() and cluck(). You'd loose the first (several) frame(s)! Jenda
In Section
Meditations
|
|