lua-users home
lua-l archive

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


On Thu, 1 Apr 2010 11:32:22 +0200
steve donovan <steve.j.donovan@gmail.com> wrote:

> That's one scheme; your class is a metatable, which has a 'fallback'
> __index pointing at the parent class, giving you an inheritance chain.
> This can hurt performance, so there's also 'fat metatable' inheritance
> where the base class members are copied into the metatable.  Classes
> get a little fatter, but assuming that there are many more objects
> than classes this is a fine trade-off.

This is, I guess, a sensible & simple mechanism:
* It's clear (a type is the set of all common attributes).
* No method lookup chain (every attribute is either on the object or on the type).
* Suptyping = multiple inheritance = mixin = merging one type with a set of new attributes.

Denis
________________________________

vit esse estrany ☣

spir.wikidot.com