lua-users home
lua-l archive

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


On 22/04/2014 12:43 AM, Dirk Laurie wrote:
Eike: > Personally, I don't know what light userdata types are good for anymore.
Ross: > The problem for me with light userdata is that they are typeless

Light userdata is designed for one situation only: interfacing with C
packages someone else has written that do their own memory management.
That should, in the case of a properly
written package, include some kind of type management.

Hi Dirk,

You use the word package twice there, and I'm not sure if you mean the same thing both times.

Depending on the scenario, C/C++ code may not include sufficient runtime type information to interface with light user data without extra dynamic type checking magic, which will need to go in the binding layer.

Speaking only for myself, in writing a binding I would prefer to make maximum use of Lua's existing dynamic type infrastructure, rather than have to layer in an extra indirection.

On the other hand, there may be challenges in making a mechanism such as Peng's useful enough for general use (i.e. shared use by all loadable modules). You'd need a way to allocate type-id slots at runtime to support multiple independently developed modules. If the number of slots is limited, then it may be too restricted to be generally useful.

Ross.