in reply to Overload and nomethd
Instances of 'parent' inherit the overload of '+' here.{ package test; use overload '+' => 'op_add'; sub op_add { ... } } { package parent; use test; use base qw(test); }
Overloading is a pretty delicate and specific thing to just toss into your class based on what your attribute classes are doing. If you insist on going this direction you describe you might be able to accomplish by setting up an accessor for this 'test' attribute of 'parent'. When it's set check to see if the object specified has the overloading you're looking for, then set it up at run-time. You'll probably need a closure to do it properly, and even then it may not work.
That's the most advice I'm willing to give. Falling back on overloading, or setting it up at run-time, are both going to make for some very confusing classes to use. I seriously suggest you rethink your design.
|
|---|