in reply to Re: inheritance weirdness
in thread inheritance weirdness
When you override a method in a subclass, you frequently need to modify or reuse the superclass behavior. So you need a construct that says "if I wasn't here, what would have been called".
But let's say you were already an inherited method. To do the lookup, you can't start in the object's superclass... you have to start in the method's superclass, otherwise you'll get into an infinite loop, calling yourself over and over.
Hence, the current behavior is precisely right, albeit a bit awkward if you don't get the purpose of the behavior. Also, the closest thing we have to "class of the method" is "package in which the method was compiled", which is not necessarily the same as "the package in which the subroutine is located", as I've illustrated in the past here. That's both a blessing and a curse, but I'll save the longer discussion for another node.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SUPER does the right thing - don't disrespect it!
by dash2 (Hermit) on Jan 27, 2003 at 12:36 UTC |