lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Friday 30 September 2005 23:23, Mildred wrote:
[...]
> Is it possible to have multiple inehritance with tolua++ w/o using
> syntax like:
> myobject.__parent__:mymethod()
> ?

This depends very much on how you build your OO system.

The system I tend to use involves physically copying the methods from the 
superclass object to the subclass object when subclassing --- I believe this 
is the most common approach. This allows very easy multiple inheritance 
because you can copy an arbitrary number of superclass objects. However, this 
doesn't allow subclasses to reflect changes to the superclass object once 
made.

Another system I know of, which I haven't used and so might get completely 
wrong, involves having a chain of class objects each of whose metatable's 
__index field points at the superclass. This *doesn't* allow multiple 
inheritance unless you have a class whose __index field contains a dispatch 
routine that searches multiple classes... and this approach is slow enough as 
it is.

And I have *no idea* if you can do multiple inheritance using a closure-based 
OO system (see http://thread.gmane.org/gmane.comp.lang.lua.general/12344) --- 
I suspect not.

BTW, has anybody done a formal collection and comparison of all the various 
Lua OO mechanisms? Because, er, there are rather a lot!

-- 
+- David Given --McQ-+ "Hydrogen fusion, the sun makes shine
|  dg@cowlark.com    | Vascular pressure makes the ivy twine.
| (dg@tao-group.com) | Because of Rayleigh, the sky's so blue.
+- www.cowlark.com --+ Hormonal fixation is why I love you." --- Zarf

Attachment: pgp0EKXKmgq8W.pgp
Description: PGP signature