On Thursday 30 October 2003 18:24, Dave Rolsky wrote:
> Well, sort of.  It messes with the symbol table of the dynamically
> constructed "child", which ends up with each parents methods.  I don't
> really want to do that.  I want to be able to have any of the intermediate
> classes call SUPER::foo() and have it do the right thing, which is my
> current stumbling block.

What is "the right thing"? Is it to call foo() in any other package besides 
the current one? If so this should be achievable with something like 

package BottomOfAll;

sub AUTOLOAD
{
        my $meth = $AUTOLOAD =~ /::(.*?)$/;
        my $call_pkg = caller();

        my $pkg = ref $_[0];

        # go through all the 
        my $super;
        for (@{$pkg."::ISA"})
        {
                next if $_ eq $call_pkg; # don't want to end up back in the same method
                last if $_ eq __PACKAGE__; # don't want to end up in the AUTOLOAD again
                last if $super = $_->can($meth);
        }

        goto &$super if $super;

        croak qq{Can't locate object method "SUPER::$meth"};
}

This still has the potential for loops if a::foo and b::foo both call 
->SUPER::foo.

Of course "the right thing" could mean something very different...

F

Reply via email to