in reply to Re^3: Trying to DESTROY() an object
in thread SOLVED: Trying to DESTROY() a (closure-wrapped) object

Thanks kennethk.

I also found that instead of doing the object redirect, I can weaken() inside of the sub re-definition on $self directly:

*$sub = sub { weaken $self if ! isweak $self; ... }

I've been doing some testing with both scenarios to see if without the $closure_self, weird issues crop up.

Replies are listed 'Best First'.
Re^5: Trying to DESTROY() an object
by kennethk (Abbot) on Dec 08, 2015 at 20:31 UTC
    I don't think that does what you want. The reference will never be weakened if you never call sub.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

      That's good... and it's for certain what I don't want. Having a sub doing random stuff after one thinks the object is out of scope could lead to spectacularly hard to find bugs ;)