# from Michael G Schwern
# on Monday 26 February 2007 03:29 pm:

>Eric Wilhelm wrote:
>> # from Michael G Schwern
>>
>> # on Monday 26 February 2007 01:50 pm:
>>> And then someone defined a $SIG{__DIE__} so now its C<<{ local
>>> $SIG{__DIE__};  eval { $obj->isa($class) } }>>
>>
>> No.  If that $SIG{__DIE__} doesn't check $^S, then it's just
>> delete($SIG{__DIE__}) and you're back to eval {$obj->isa($class)}
>> and balance is restored.
>
>You don't want to delete someone else's $SIG{__DIE__}.

No, I do.  Why would anyone else's $SIG{__DIE__} be in my code?  Now, 
maybe you're going to say that someone might use my module and be upset 
because their broken $SIG{__DIE__} is broken.

>And how can 
> you know if it checks $^S (most don't)?

Maybe some juggling of exit and die.  Hmm, sounds like a job for 
chromatic.  Acme::OhNoYouDidn::t?  Or, you could just curry it into a 
sub that does check $^S if you wanted to be safe and weren't concerned 
about the call stack.  Or you could always just walk down the hall and 
tell whoever wrote it to fix it.

> Or was that a round-about 
> way to say "you should always check $^S in your $SIG{__DIE__}"

Yeah.  No, I don't actually delete it.  But if you're having problems, 
delete() may well be the answer.

> which 
> would be great but nobody does which brings me right back to "it
> shouldn't be so hard to do it right!"

Why doesn't anybody do it right?  Yes, the docs say that it was an 
accident that $SIG{__DIE__} gets called from within an eval and "that 
may be fixed in the future."  But, it's very clear in both perlvar and 
perlfunc#die, so why bother with the eval {local $SIG{__DIE__}; ...} 
mess?  Just cause broken code to break instead of working around it.

--Eric
-- 
Anyone who has the power to make you believe absurdities has the power
to make you commit injustices.
--Voltaire
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to