in reply to Re: How to get a reference to a superclass method?
in thread How to get a reference to a superclass method?

You're kidding, right??!!

Of course, you're not kidding, because it works just fine. If someone could point me toward an explanation of why that works, I'd be very grateful.

It seems that my "just type and hope Perl figures it out" approach was closest, but I couldn't get a permutation of $class->SUPER::$meth to compile.

Replies are listed 'Best First'.
Re^3: How to get a reference to a superclass method?
by Anonymous Monk on Feb 10, 2012 at 19:47 UTC
      I guess what I was missing is that "SUPER" isn't as magical as I thought. I understand that $c->$m($x) is just $m($c, $x) but I was reading "SUPER" as somehow being associated to the class, not being part of the method. To abuse some notation, I was reading "$c->SUPER::get" as more like "($c->SUPER)::get" than like "$c->(SUPER::get)". That's not right; functions are the real things, and classes are the illusion.

      At http://perldoc.perl.org/perlobj.html#Method-Invocation it says "...you may use the SUPER pseudo-class to tell Perl to start looking for the method in the packages named in the current class's @ISA list." When I've read that in the past, I guess I thought "current" referred to "that thing just to the left of the '->'" but it means "the thing after 'package' up above".

      I feel like I understand better now.

        Yes, it means the thing to the left, or the package the thing on the left is blessed into

        $ perl -MCGI -le " print CGI->new " CGI=HASH(0x3f8c8c) $ perl -MCGI -le " print ref( CGI->new ) " CGI $ perl -MCGI -le " print CGI->new->can(q/SUPER::VERSION/) " CODE(0x3f8e5c) $ perl -MCGI -MSub::Identify=:all -le " print sub_fullname( CGI->new-> +can(q/SUPER::VERSION/) ) " UNIVERSAL::VERSION

        These two might be easier to digest (or reference) https://metacpan.org/module/DROLSKY/perl-5.15.6/pod/perlootut.pod, Modern Perl