develooper Front page | perl.perl5.porters | Postings from December 2018

[perl #133678] Parent Package runs Methods of the Child Package

From:
Tony Cook via RT
Date:
December 4, 2018 22:59
Subject:
[perl #133678] Parent Package runs Methods of the Child Package
Message ID:
rt-4.0.24-29579-1543964373-629.133678-15-0@perl.org
On Fri, 23 Nov 2018 05:38:56 -0800, hugo@domibay.org wrote:
> Originally I wrote the Code as
> 
> package Family::Child;
> sub baseMethod {
>   my $self = $_[0];
>   $self->SUPER::extendedMethod();
>   print "and the Child chuckles.\n";
> }
> 
> And I was expecting that "SUPER::" would UPCAST "$self" into "Family"
> and "Family::extendedMethod()" would call "Family::baseMethod()" and
> not "Family::Child::baseMethod()".
> 
> Now I see that Upcasting does not happen in Perl.

This kind of happens in C++ if you're using non-virtual methods, but that's an efficiency thing rather than a desired outcome.

Rejecting this ticket.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133678



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About