Some of you may have seen the discussion going on in p5p about the
current design/implementation of SUPER:: type dispatch. Without
wishing to rehash the whole debate, the current way SUPER:: works
is based on the current package method at the time that SUPER::foo was
compiled, thus, given:


    @A::ISA = 'P';
    @B::ISA = 'Q';
    @C::ISA = 'R';

    package A;

    sub B::foo {
        package C;
        shift->SUPER::foo;
    }

then 'A->foo' would end up calling P::foo. B->Foo would end up calling
R::foo (by way of B::foo), and C->foo ends up at R::foo as well.

I would like this to work slightly differently. I want to be able to
do, for instance (and assuming my understanding of perl6 syntax is
correct...) 

   &A::foo = sub { my $self = shift; $self->SUPER::foo }

and have it dispatch to P::foo (by way of A::foo). This means that
SUPER:: would have to dispatch based on which stash the method was
found in, rather than the package in which it was compiled.

Now it turns out that this sort of dispatch will break some existing
code, so I'm not arguing that this kind of dispatch should be the
default, but I would argue that it should be *possible* to write some
SUPER.pm to provide this kind of behaviour (correctly, for all cases),
something which is not possible with the current implementation of perl.

Please, before you comment to tell me I'm a fool, take a look at the
thread in p5p. We've covered at lot of this already and I accept that
right now it is very hard (if not impossible) to get this behaviour in
the current version of perl without some (as yet unspecified) massive
slowdown, but I still think the behaviour I'm asking for would be
useful. (See my earlier post about anonymous class factories, which is
what led me to discover that SUPER:: didn't work quite how I thought
in the first place...)

-- 
Piers

Reply via email to