in reply to Re: Re: die & DESTROY - but not at the same time?
in thread die & DESTROY - but not at the same time?
Uh... well, it's a special block... so it's... uh... handled "specially". <insert lots of handwaving>
Frankly, I'd be more than happy to listen to a real explanation from someone who knows. :-)
By the way, as of 5.6, dies within a DESTROY are visible if you run with warnings enabled. Here's the relevant passage from perldoc perl56delta:
And another example:Failures in DESTROY() When code in a destructor threw an exception, it went unnoticed + in ear- lier versions of Perl, unless someone happened to be looking in + $@ just after the point the destructor happened to run. Such failures +are now visible as warnings when warnings are enabled.
$ perl -wle 'sub DESTROY { die "dead" }; { bless \my $o }' (in cleanup) dead at -e line 1.
Update: Also worth noting, the entry from perldoc perldiag:
That implies that if DESTROY prints the same thing each time, the warning will only be printed once. If the warning is different each time, however, it should be printed each time. More examples to substantiate that:(in cleanup) %s (W misc) This prefix usually indicates that a DESTROY() met +hod raised the indicated exception. Since destructors are usua +lly called by the system at arbitrary points during execution, +and often a vast number of times, the warning is issued only on +ce for any number of failures that would otherwise result in the s +ame message being repeated.
$ perl -wle 'sub DESTROY { die "dead" }; { bless \my $o; bless \my $p +}' (in cleanup) dead at -e line 1. $ perl -wle 'sub DESTROY { die "dead: $_[0]"}; { bless \my $o; bless \ +my $p }' (in cleanup) dead: main=SCALAR(0x805f0d4) at -e line 1. (in cleanup) dead: main=SCALAR(0x805f164) at -e line 1.
Edit: Replaced
with a better example.
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: die & DESTROY - but not at the same time?
by mildside (Friar) on Aug 14, 2003 at 01:50 UTC |