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? LizThread Previous | Thread Next