On Fri Sep 27 18:39:25 2002, amm2@andrew.cmu.edu wrote:
I'm not asking for global destruction to happen before END, I only ask
that objects are DESTROYed before END of their package is called.
You may have objects with methods that talk to the same socket for
example, via a private communication protocol.
I would like each object to finish the (application-layer)
during DESTROY, and END to close the socket itself.
If you're not guaranteed that END will be executed after any DESTROY
that same package, it makes the problem very difficult. This is a
example, but there are applications wich require much more elaborate
cleanup procedures.
So, the END routine of a package should still see all global variables
I'd like perl to effectively do: '$package_ref=undef' right before it
END of that package, even for $package_ref's that are global
This would be a major enhancement to object-oriented Perl.

I’m afraid it’s too late to change this now.

There is plenty of code that expects to be able to use objects within an
END block, so this code would break things.

If you need to have all objects of a class destroyed (or at least their
destructors run) before END, you can do it yourself by caching them in a
field hash.

Then, at the beginning of the END block, just call ->DESTROY (or a
similar method) on all the existing objects. You will need to make sure
your DESTROY methods are idempotent. (E.g., sub DESTROY { my $self =
shift; return if $self->{destroyed}++; ... })

See the END block in lib/KSx/Simple.pm in
CREAMYG/KinoSearch-0.30_121.tar.gz and the one in DBM::Deep for examples.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
postedOct 3, '10 at 9:34p
activeOct 3, '10 at 9:34p

1 user in discussion

Father Chrysostomos via RT: 1 post



site design / logo © 2022 Grokbase