my $x = bless {}, SomeClass; my $y = $x; say ref($y); # prints 'SomeClass'; my $z = bless {}, SomeOtherClass; ...do some magic so that $x 'becomes' $z... # note this also changes $y: say ref($y); # prints 'SomeOtherClass'
The question arose when I was thinking of implementations of lazy-loading. Have a proxy object stand in for the lazily-loaded object, and the proxy will load the real object only when it really is needed. Instead of having the proxy forward method calls to the real object, it would be nice to have the the proxy 'become' the real object.
In reply to object swizzling? by perl5ever
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |