I'm kwalitee testing Data-Calc for the phalanx project. This has been a very enlightening experience for me. I just stepped back into the testing mode today and realized why I stopped due to aggrivation before.
The Delta_Days function in Date-Calc croaks on invlaid data. I just hate when modules decide when to stop my program from running. Is it so hard to just return a error code? Am I the only one that is irritated at this?
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 get a wakeup call when something goes wrong.
-sam
Re:die() != exit()
kane on 2003-09-25T08:22:14
And i agree with the author -- i'm perfectly capable of deciding myself when a program should die.
And note that/none/ of the perl built-ins die if you do something that doesn't work. To amend my frustration, i've written a module a while ago called No::Die which you might find useful in this context.
I use the same policy in CPANPLUS, since i do not want it to ever die.
Re:die() != exit()
perrin on 2003-09-25T16:14:59
If you want to see how bad people are about checking return codes, just look at DBI. Most DBI programs do not check the return of every method call, even though any one of them can return a code that indicates a catastrophic failure. The RaiseError option that makes DBI die when these things happen is a much better approach, since it ensures that your program will stop if it fails to perform a DBI operation unless you care enough to trap it with eval{}.Re:die() != exit()
grantm on 2003-10-14T22:52:15
And note that/none/ of the perl built-ins die if you do something that doesn't work. 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.
Re:phalanx
SparkeyG on 2003-09-24T17:14:29
Look here. Just another nod that maybe this needs a wider announcement.;)