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

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

From:
Yitzchak Scott-Thoennes
Date:
December 2, 2004 23:21
Subject:
Re: [perl #32714] Objects destroyed in the wrong order during glo bal destruction
Message ID:
20041203072047.GA3056@efn.org
On Fri, Dec 03, 2004 at 01:01:20AM +0100, Paul Johnson <paul@pjcj.net> wrote:
> 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.

Does the first END sub do something else also?  Why not skip the CHECK
and just have a regular END sub that inserts a last END sub?

No dedicated XS needed, at least as of 5.8.1:

perl -we'use B qw/end_av/; END { print "baz" } END {print "bar"; push @{end_av()->object_2svref}, sub { print "quux" } } END { print "foo" }'



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