lua-users home
lua-l archive

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

>>> 01/19/05 02:26PM >>>
You mean 5x access time for custom function.  And that's not including

the logic within.

Yes, it would look like this (assuming that you do put a _base
field in each class):

c.__index = function(t,sym)
     t = getmetatable(t)
     while t do       
       local r = t[sym]
       if r then return r end
       t = t._base

as opposed to the simple 'c.__index = c', which
is highly optimized.

>"Nested metatables", I presume, is '__index' with a table reference,
>I right?

That's it - and for inheritance you give your metatable its own
metatable, and so on ad inf.  So if lookup fails in your class, it
automatically looks in the class' base class (read: metatable)

Little tests can give interesting information!

steve d.