Klaas-Jan Stol wrote:
Hi,
I was wondering if it is possible to call specific methods from a parent
PMC from another method in your (child) PMC, for some other object than
SELF.
Yes, see below.
My situation may be a bit complex, so I'll explain:
I have a LuaTable PMC, extending the Hash PMC.
I override the "add" method, because users may override the "add" method
for Tables (which normally does not exist). These user-overriden methods
are stored in yet another LuaTable. This other LuaTable, the "metatable"
of methods (like 'add', 'subtract', etc.) is stored as a property
(setprop).
Did you try to just used Parrot's MMD system instead of the double
indirection through properties and metatables? I.e. instead of putting
the user-defined 'add' sub into the metatable just 'store_global' the
sub into the LuaTable namespace.
So, something along the lines of
SUPER.VTABLE_get_pmc_keyed(INTERP, metatable, key);
// call "get_pmc_keyed" in the Hash PMC for the object 'metatable'
Have a look at classes/orderedhash.pmc. There is e.g.:
Hash.SUPER();
or
Hash.SELF.get_integer_keyed_str(key);
As you know that the parent isa Hash PMC, this will work fine. And you
can of course just call the function too.
Thanks,
klaas-jan
leo