in reply to if (UNIVERSAL::isa($r, ref $l))
Assuming Number::MixedFraction, and Number::Fraction::Tk are both happy to inherit the 'add' method from Number::Fraction (and get a Number::Fraction as the result) then wouldn't it make sense for Number::Fraction::add to be general enough to work in that scenerio?
I'd say so (although I agree with ihb and would use __PACKAGE__ rather than hardcoding the class name).
Ideally subclasses should do at least as much as their parent class, and possibly more (or, in design by contract speak - they must meet all their parents class invarients and post-conditions, and its own or its parents pre-conditions). I'd worry about the code if this wasn't true.
|
|---|