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

Um, why it works? Because perl syntax is perl syntax :)

$ perl -le " q/warn/->( 6,6 ) " Undefined subroutine &main::warn called at -e line 1. $ perl -le " sub warn { die @_ } q/warn/->( 6,6 ) " 66 at -e line 1.

Modern Perl, references quick reference /Re (tilly) 1: References quick reference

Replies are listed 'Best First'.
Re^4: How to get a reference to a superclass method?
by mcdave (Beadle) on Feb 11, 2012 at 14:59 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