lua-users home
lua-l archive

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


2011/8/28 Jeff Smith <spammealot1@live.co.uk>:
> Does my understanding sound correct on that ? That was expected from the
> limitation you mentioned ?

Yes, this is the implication of modifying the metatable of light
userdata - you have only one (global) metatable for light userdata.

> OK, so that kind of makes light userdata pretty much useless for real world
> examples where more than one structure type is needed, or am I missing
> something here, it sounds too big a limitation so I am doubting my
> understanding is correct.

As I said, it is useful for opaque foreign (non-Lua) types like
handles, which you use in a non-object-oriented way (i.e. get them as
return values and pass them as parameters to functions).

> I guess I need to look at using full userdata now as an alternative way to
> go, I didnt really follow Michals follow up post , but I have only read it
> once so far, I need to re-read that one

Sorry for not being clear, I wanted to be brief. I recommend you read
the book Programming in Lua, mainly the chapter about user-defined
types in C [1], where everything you seem to need is explained step by
step (actually, I recommend reading the whole book when you have the
time :).

[1] http://www.lua.org/pil/28.html