How to super?

Will Coleda will at coleda.com
Fri Oct 30 13:27:49 UTC 2009


On Fri, Oct 30, 2009 at 12:54 AM, Will Coleda <will at coleda.com> wrote:
> Ages past, I wrote a subclass of my TclArray (itself a PMC with a
> parent of Hash) to provide [trace] functionality for the array.
>
> I overrode get_pmc_keyed, did some work to make the trace work, and
> then ended with:
>
>  # Delegate to our parent..
>  $P0 = getattribute self, ['TclArray'], 'proxy'

Apparently the trick (pmichaud++) is to change TclArray to Hash. We're
getting the proxy that points to the first PMC (not class) in our
parent chain.

This works for me, as TclArray didn't override the vtable I was
interested in, so I really wanted Hash's implementation of the vtable
anyway.

There should probably be better syntax for this, and one that allows
us to dispatch to non-PMC parents as well.


>  .local pmc result
>  result = $P0[key]
>  .return (result)
>
>
> However, this was disabled for some time, and when I tried to
> re-enable it, I started getting:
>
> No such attribute 'proxy' in class 'TclArray'
>
> Which is not unexpected, as now TclArray is now written in PIR, not C
> (as it was when this was originally written.)
>
> So, how does one dispatch to one's parent's vtable? Looking for
> super|parent under docs, src/ops and src/pmc doesn't show any likely
> candidates.
>
> --
> Will "Coke" Coleda
>



-- 
Will "Coke" Coleda


More information about the parrot-dev mailing list