in reply to Re^2: Inside-out objects inheriting from hash-based classes
in thread Inside-out objects inheriting from hash-based classes
But what happens if you need/want to make explicit calls to a super class?
print( $object->Borg::comment(), "\n" );
Updated/expanded for clarity
Assume that you have a method of the same name in Borg as you do in Foo:
package Borg; sub comment { return $_[0]->{default_threat}; }
If I want to explicitly call the Borg version of that method, I'd call it as $obj->Borg::comment(). However, that's equivalent to this:
Borg::comment( $obj );
Therefore, if Borg::comment is expecting an object of type Borg and intends to muck with its internal structure directly, this will fail since the real Borg object is hidden in a closure in Foo and keyed to $obj and $obj is just the blessed reference for the inside-out object.
Or have I missed something?
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Inside-out objects inheriting from hash-based classes
by jdhedden (Deacon) on Dec 08, 2005 at 05:27 UTC |