lua-users home
lua-l archive

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


I am trying to understand the right way to use the light userdata (in Lua 5
of course).

As I understand it, light userdata is just a pointer value and has no
metatable (since it's light) and tag (since it's Lua 5).

The only way I see to do anything with these pushed values is to call bound
C functions with them as arguments.  [Since they have no metatable, you
can't do any real operations on it.]

So, you call your bound C function with this argument on the stack.
Presumably, in your C function you want to grab the light userdata and
manipulate it (perhaps calling other C functions, invoking methods with it,
etc.).  But, since it lacks any tags, how are you supposed to do anything
typesafe with this value?

It seems like any typesafe operation would require the heavy userdata with
lua_boxpointer.  But that begs the question, what's the use of the light
userdata?

Any insights are appreciated!

Thanks,
Evan