in reply to Error handling - how much/where/how?
There's a style of programming where you make "executable comments" that also raise errors when something that should be true isn't: assertions in perl5.9.0.
The above is from Schwern's Carp::Assert. I think there are a number of other modules that do this as well, and I'm not sure which is best, because I only started experimenting with assertions myself recently. But it might be something to learn about if you are spending a lot of time meditating about commenting and error checking.# Take the square root of a number. sub my_sqrt { my($num) = shift; # the square root of a negative number is imaginary. assert($num >= 0); return sqrt $num; }
|
---|