I noticed that when you call a superclass's methods, you need to do something like this :
my $self = $class->SUPER::new();
Why isn't that:
my $self = $class->SUPER->new();
I suspect because $class->SUPER->new()
would normally be the same as $class->SUPER()->new()
. But there isn't a $class->SUPER()
function, and its not clear what that would return.
On the other hand, $class->Foo::Bar
has always been a valid way to call a method directly by full name, so making a special package-like thing — SUPER
— fits in better. (I suspect that you could actually implement SUPER
as a package, and maybe it historically was, I don't know)
PS: Take a look at the mro
package, and $self->next::method
. Also, take a look at Moose if you're going to do serious OO work in Perl.
In short, SUPER isn't a method. It's a virtual package. It's documented in perlobj under the "Method Invocation" section.
Note, however, that SUPER bases itself on the current package, not the package of the instance you used it with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With