lua-users home
lua-l archive

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

> It's interesting to compare various ways of implementing 
> inheritance in lua.
> Here are some numbers:
>    - global function call                     1.0
>    - copying methods into class        1.5
>    - custom __index  function            5.0  (!)
>    - nested metatables                      2.0
> In summary;  method dispatch isn't too bad, unless
> you use a custom function to look up symbols.
> Generally keeping 'fat' classes (that include all
> methods) is better; this will not depend on
> the depth of inheritance.

Good, I like 'fat' classes...that's mostly through ignorance of how else 
to do it, but now I have a performance justification :-)

> Of course, your mileage may vary...

Nautical, Roman, Imperial or Country miles?