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

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.

Replies are listed 'Best First'.
Re^5: How to get a reference to a superclass method?
by Anonymous Monk on Feb 11, 2012 at 15:15 UTC

    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