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

For the inheritance tests, a method of the base class
was called by an object of a derived class, twice
removed.

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.

Of course, your mileage may vary...

steve d.