On 5/18/07, Greg London <[EMAIL PROTECTED]> wrote:
[...]
> >You're looking at the wrong part of the code. I'm referring to how I
> >made sure to capture refaddr before creating the anonymous sub so that
> >the anonymous sub did not have $object in it anywhere. That keeps
> >$object from being in the closure, which means that $object won't be
> >kept alive by a reference from the subroutine.
>
>
> Ah, take my original code:
>
> my $instance_to_skip = $mut;
> my $intercept = sub {
> my $obj=shift(@_);
> if($obj eq $instance_to_skip) {
> return;
> } else {
> $obj->(@_);
> }
> };
>
> And change the first line to
>
> my $instance_to_skip = $mut . '';
>
> This forces the instance to be stringified,
> and then you're storing the string in your
> closure, not a reference.
Right. I avoided that because of the possibility of an overload, but
that's the natural implementation.
My code was untested, not un-thought-through. ;-)
Cheers,
Ben
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm