lua-users home
lua-l archive

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


on 8/4/03 7:46 AM, RLake@oxfam.org.pe at RLake@oxfam.org.pe wrote:

> Leaving that aside, there is a fairly simple way of letting a userdata
> get at a collection of Lua objects: put the Lua objects in the userdata's
> metatable. Of course, this means creating a unique metatable for each
> userdata, which is a bit of overhead. But if you use integer keys
> starting from 0 or 1, it is not too much overhead.

Interesting idea. So, one would have essentially the following structure:

    userData.__metaTable = {
        < first referenced object >,
        < second referenced object >,
        ...
        __index = < shared userdata method table >
    }

Or __index points to a function that is smart about knowing where to look.

Mark