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.
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).

So, when trying to add 2 tables together, this is what happens:

1. "add" in LuaTable is called (because of "Px + Py")
2. while in add, check if this LuaTable (you could say "SELF") has a property "metatable". 3. if it has such a metatable, check if it has a field "add" (this would contain the user-defined add function for adding tables).
4. if is has not, give an error saying you can't add tables.


However, in step 3, the "get_pmc_keyed" method is called of this 'metatable' PMC (which was stored as the "metatable" property). Users may *also* override _these_ methods (so, set/get_pmc_keyed). That would mean, that while handling this "add" method, another user-overriden method is called. This should not happen. So, what I'd like to do, is to call the "get_pmc_keyed" in the Hash PMC, for this 'metatable' PMC.

So, instead of doing this:

   VTABLE_get_pmc_keyed(INTERP, metatable, key);

which calls the get_pmc_keyed method of the LuaTable PMC, I'd like to call this get_pmc__keyed method of the Hash PMC for this metatable object.

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'

I hope my question is clear. Is there any way to do this?


[[ A somewhat related question to this is: would it be handy to add syntax to call an arbitrary method from a parent class? So, in pmc2c.pl, it says it's possible to call a method in a parent class by means of:

   SUPER(...)

but that only allows for calling the _same_ method (so, when in the method "add" for example, you can only call SUPER's add, not SUPER's subtract or something). It might be handy to be able to do something like:

   SUPER.method(...)

Or is there any other way to do this?
]]

Thanks,

klaas-jan

Reply via email to