in reply to SUPER delegation fails because class name getting munged (somehow?)

<code>$class->SUPER...<code> is a bug in the general case, although in your specific case it should DTRT. SUPER is resolved *from the current package*, not from the object or class it appears to be called on.
  • Comment on Re: SUPER delegation fails because class name getting munged (somehow?)

Replies are listed 'Best First'.
Re^2: SUPER delegation fails because class name getting munged (somehow?)
by GrandFather (Saint) on Feb 24, 2011 at 20:57 UTC

    How is that a bug? My expectation would always be that SUPER is resolved in the context of the current package and that is the way it is documented in perlboot and perltoot along with pretty much anywhere else I've seen it mentioned in documentation.

    True laziness is hard work

      This was actually something that I've never really thought about and at first blush was surprising (although given five minutes of thought, it makes perfect sense). The fact that $class->SUPER::method() doesn't consider the value of $class at all could be unexepected since in typical use, the method is resolved relative to the invocant. Moose's bare super keyword avoids any confusion by removing the invocant altogether. This makes it (virtually) impossible to try and call some other class's (or object's) parent method via SUPER (or super in Moose's case).