lua-users home
lua-l archive

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


Is it generally better to perform type conversion before calling into
Lua or after?

For example, lets say I have some custom C structure and I want to get
it into Lua.  I'm already in the C code and I'm going to be calling a
function in Lua.   Is it better to convert the type into a Lua type
and pass that into the lua_call() or would it be better to pass a raw
pointer lightuserdata into Lua and then from within Lua call a C
function to convert the type?

Converting after calling into Lua seems to give a bit more safety
because you're moving your call into Lua as soon as possible.
However, the type needs to be converted from a C function anyway so it
seems a little cleaner to convert it before you call into Lua.  Either
method will work but I'm wondering if anyone has had experiences where
one method was better for some reason or another.

CR