develooper Front page | perl.perl5.porters | Postings from December 2004

Re: [perl #32714] Objects destroyed in the wrong order during global destruction

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
December 3, 2004 01:58
Subject:
Re: [perl #32714] Objects destroyed in the wrong order during global destruction
Message ID:
f06110433bdd5e8a1833b@[192.168.56.3]
At 1:01 AM +0100 12/3/04, Paul Johnson wrote:
>On Thu, Dec 02, 2004 at 10:03:59PM +0100, Elizabeth Mattijsen wrote:
>  > I think it would be possible to create a module (pragma) that would
>>  ensure an orderly (as in lifo) destruction of objects.  The only
>>  thing I miss is a way to make sure a specific END code block is
>>  executed as the very last END block.  Is there a way to do this?
>>  Possibly in XS?
>
>Devel::Cover does just this.  It's something of an unholy mix of XS and
>perl subs for various arcane reasons, at least some of which are
>unlikely to be valid any more.
>
>The way it works is that in a CHECK block an XS sub is called which
>installs a perl sub as as the first END sub.  This is done by unshifting
>onto PL_endav.  When that sub is called as the first END sub it calls
>another XS sub which installs another perl sub as the last END sub by
>pushing it onto PL_endav.  That newly installed sub should be the last
>END sub called.  Unless one of the subsequent END subs installs another
>END sub.
>
>It's probably easier to look at the code.  It's on CPAN.
>
>But if you do this, our two modules will fight.  Which means I'll have
>to make my final END sub not really the final one any more, but have it
>install another END sub which really will be the last ;-)

How about if Devel::Cover would supply a method/subroutine to install 
the "last" END block?  Then it would be easy to ensure that 
Devel::Cover's is really the last.

On the other hand, having Devel::Cover as a prerequisite may be quite 
overkill.  Maybe this functionality should be put into a seperate 
module that would become a prerequisite for both?


Liz

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About