in reply to Using SUPER in dynamically generated subs
The problem with this, is that SUPER refers to the @ISA of the class it is COMPILED into, not the class of $self at runtime.I'm not sure why you think this is "a problem".
This is the only sensible way for it to work.
You don't want to find the same named method in the superclasses of the object. You must find the same named method in the superclasses of the class in which you are compiled.
Consider X @ISA Y @ISA Z. Now, call method doit on an X, which isn't found, so we go up to class Y. In Y::doit, we want to call SUPER::doit. We cannot look at the @ISA of the object (which is an X), because that'll come right back around to us again! We must look in the @ISA of the class to which we belong (in this case, Y::doit), yielding a potential call to Z::doit.
So, if I'm following what you're trying to do, you'll be making classes that cannot be subclassed properly, because they'll be looking at the class of the object to get parents, not the "class" of the method. Broken.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using SUPER in dynamically generated subs
by chromatic (Archbishop) on Nov 14, 2006 at 03:56 UTC | |
|
Re^2: Using SUPER in dynamically generated subs
by clinton (Priest) on Nov 14, 2006 at 10:33 UTC |