|Don't ask to ask, just ask|
Duh. What am I missing about inherited constructors?by sundialsvc4 (Abbot)
|on Nov 04, 2010 at 13:24 UTC||Need Help??|
sundialsvc4 has asked for the wisdom of the Perl Monks concerning the following question:
Okay, my mind went blank, much too late last night (and not for bottled reasons). I coded what I intended to be a package with an inherited constructor, but the inherited routine was never called. The code looked like this: (Perl 5.10.0)
Edit: Typo in constructor-call removed.
When I set croak calls and other things in the supposedly-inherited routine (in Foo), they never went off. But the routine in Bar did.
Furthermore: other methods defined in Foo (but not in Bar...) were available. So, it’s not like Perl didn’t know what package I was talking to ... it’s just that a routine defined in the child-class was ignored in favor of the parent, and I don’t know quite why.
Sure, I could define an initialize() method and call that from the constructor, but I want to understand what eluded my then-befuzzed brain.
Have I been this-quickly and so-utterly spoiled by Moose? :-)