in reply to Re: Per-object DESTROY
in thread Per-object DESTROY

It's not my object. I'd need to either install a DESTROY method into the Archive::Extract object violating its implementation or write an object which I could hang my DESTROY-time code off of. tilly's ReleaseAction handles this case nicely. I just pass in my destroy code and make sure the ReleaseAction object is destroyed at the same time as the object.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^3: Per-object DESTROY
by varian (Chaplain) on Jul 08, 2007 at 13:53 UTC
    ReleaseAction would require you to synchronize the out-of-scope moment between the two objects.

    Wouldn't the classy way be to subclass Archive::Extract just inheriting its methods, and to implement your own DESTROY method in the subclass that invokes SUPER::DESTROY as its last action?

      In this case, the destruction moment isn't really identical. It would have been cheap and easy to join the two and it was my first thought. A better idea is to discard the archive object as soon as I've used it up and then retain the cleanup handle until I'm finished working with its extracted contents.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊