NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
die() != exit() (Score:2)
Consider, for example,
print(). How often do you check the return value? But wouldn't you like to know if it didn't work in the middle of complex program? Exceptions allow the caller to program lazily (not checking return codes) and still geRe:die() != exit() (Score:1)
And note that
To amend my frustration, i've written a module a while ago called No::Die [cpan.org] which you might find useful in this context.
I use the same policy in CPANPLUS [cpan.org], since i do not want it to ever die.
Re:die() != exit() (Score:1)
Re:die() != exit() (Score:1)
substr will die on when used as an lvalue and the range is invalid.
use & require will die on failure.
Various other builtin functions will die if the Perl binary lacks the relevant support.
phalanx (Score:2)
Re:phalanx (Score:1)
dying is good (Score:2)
In general, with my recent modules I've been trying to adopt a consistent behavior of "die on mutation, die on bad params, return false on accessor".
In other words, if you try to mutate/construct an object in an illegal way, it throws an exception. If a method takes parameters and you pass invalid parameters, it dies. If you try to simply retrieve some information that isn't available, it returns false.
This is, IMHO, a pretty sensible