Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Error handling - how much/where/how?

by tphyahoo (Vicar)
on Jun 13, 2005 at 08:40 UTC ( #466082=note: print w/ replies, xml ) Need Help??


in reply to Error handling - how much/where/how?

"I've been told that comments should amount for the half of your code"...

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.

# 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; }
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.


Comment on Re: Error handling - how much/where/how?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-04-20 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls