in reply to Re^2: SUPER in OOPerl is dumped with $self
in thread SUPER in OOPerl is dumped with $self
Which is exactly as it should be - that's the nature of polymorphism.
This isn't anything unique to Perl. Shortly after reading the original thread, I talked to a friend who's a Java programmer. He's been writing Java more-or-less exclusively for as long as I've known him (we met in 1999) and never touched Perl in his life. When I told him about the original post and that child::tellName was called instead of person::tellName, his exact reply was, "And that surprised him?"
If you want to ignore polymorphism and have person::introduce always call person::tellName instead of any overridden version, then change the call in person::tellName from $self->tellName(); (which calls any overrides which may be in place for $self's class) to person::tellName($self); (which always calls person's version regardless of $self's class). I've already posted a revised version of the sample code which demonstrates this in the other thread at Re^4: my $self is stumped!.
|
|---|