Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^9: Modern Perl Programming Highs and Lows

by educated_foo (Vicar)
on May 10, 2009 at 22:45 UTC ( #763162=note: print w/replies, xml ) Need Help??

in reply to Re^8: Modern Perl Programming Highs and Lows
in thread Modern Perl Programming Highs and Lows

Those things you mention fall into the "doctor, it hurts when I do this" category. Normal code shouldn't need DESTROY at all, and if it does, it should be extremely careful. And if you're creating complex overloaded exception objects, you have already lost. What does your test module's overloaded $SIG{__DIE__} do with a module that itself overloads $SIG{__DIE__}?

Sure, it's possible to build ever-more-complicated exception mechanisms with lots of corner cases, and to require more testing modules to control them. Sometimes you may even be forced into this silliness. But since you're inviting a world of hurt by doing so, you should ask yourself first whether a simpler solution could work.

  • Comment on Re^9: Modern Perl Programming Highs and Lows

Replies are listed 'Best First'.
Re^10: Modern Perl Programming Highs and Lows
by diotalevi (Canon) on May 11, 2009 at 02:13 UTC

    No, none of this is "it hurts doctor" stuff. It's quite normal to have exception objects. It's normal for exception objects to have stringification. It's unusual but not not bad to have a destructor. It is bad to fail to protect your caller against $@ clobbering but mistakes can happen. It's pretty unusual to see your tests $SIG{__DIE__} get overridden and it's worth automating the instrumentation of that happening. Mostly, I really like Test::Exception because with perl, you must be paranoid and this lets me outsource my paranoia.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2019-09-21 09:27 GMT
Find Nodes?
    Voting Booth?
    The room is dark, and your next move is ...

    Results (271 votes). Check out past polls.