perl5ever has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: object swizzling?
by ELISHEVA (Prior) on May 05, 2009 at 19:12 UTC | |
|
Re: object swizzling?
by moritz (Cardinal) on May 05, 2009 at 19:49 UTC | |
by perl5ever (Pilgrim) on May 05, 2009 at 21:25 UTC | |
by Anonymous Monk on May 06, 2009 at 12:54 UTC | |
|
Re: object swizzling?
by ig (Vicar) on May 05, 2009 at 21:11 UTC | |
|
Re: object swizzling?
by roubi (Hermit) on May 05, 2009 at 19:34 UTC |