develooper Front page | perl.perl5.porters | Postings from March 2008

Re: local $@ has an unwanted side effect

Thread Previous | Thread Next
Mark Mielke
March 21, 2008 10:46
Re: local $@ has an unwanted side effect
Message ID:
David Nicol wrote:
> On Fri, Mar 21, 2008 at 11:52 AM, Abigail <> wrote:
>>  Such code would fail if we'd introduce automatic localization of $@.
>>  Is that worth it?
> no.
> What code would fail if the order of localization restoration and
> assignment to $@ were switched?
Any code that is exhibiting an error that is being silenced? :-)

I believe I have such code. I choose to local $@ in some DESTROY 
methods, because at DESTROY time (and especially if at end-of-program), 
there is no reasonable way of trapping certain errors. Now, I suspect I 
use eval to trap all errors in this case, but if my code has any bugs 
that were silent from this particular consistent-but-broken behaviour 
being discussed, then they would become exposed, and my code is known to 
behave acceptably at present (at least in terms of how the user sees 
it), but if it suddenly started dying during exit where it previously 
did not, they might be surprised and upset?

Perl's exception model sucks - it always has. Tweaking it for cases like 
this isn't the answer. It needs a replacement. I haven't followed Perl 6 
in a few years due to a loss of interest, but I think that is where it 
needs to be fixed. Fixing Perl 5 is almost a dead goal.


Mark Mielke <>

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About