in reply to Question on use of Super with OO programing
If you look at the first snippet again, you'll see that it passes along its arguments to the inherited kick() method via
Since an object reference is always the first parameter passed when a method is invoked via '->', unless you the object reference from the argument list, you'll get two of them if you pass @_ to another object method.$self->SUPER::kick(@_);
The first fragment could have been written to do
though this means that the object reference isn't available later in the method. Since there is no later in either case, it's not a problem. But if you needed to do more after invoking the inherited kick() behavior, you'd be out of luck.sub kick { shift->SUPER::kick(@_); }
Explicitly removing the object reference from the argument list and storing it into $self is also stylistic. It helps the reader quickly realize that they are looking at an object method.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Question on use of Super with OO programing
by djantzen (Priest) on Jan 19, 2003 at 18:34 UTC |