lua-users home
lua-l archive

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


Jamie Webb wrote:

On Mon, Jul 26, 2004 at 08:17:20AM -0700, Mark Hamburg wrote:
If you can live with single-inheritance, my scheme using indices in the
metatable will work with the type-testing technique used in Oberon. Single
inheritance allows us to know that a class is at a particular depth in the
inheritance tree. The metatable for a class can then include the appropriate
light userdata for each class in its inheritance hierarchy. Testing for
class membership then becomes something like:

   luaObj.metatable[ classInfo->depth ] == classInfo

You can do something rather similar that works with multiple
inheritance by checking something like:

luaObj.metatable[ pushlightuserdata(classInfo) ] == true

-- Jamie Webb


I see the idea. It looks good since it avoids the lua_getref in my solution. I'm going to try that ... And yes, I have multiple inheritance so I cannot use the first method. But it's interesting too.