lua-users home
lua-l archive

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


Rolf,

It sounds like you're asking how you can hold on to a reference to a
Lua function from the C side. The most common way this is done is with
the registry: when the function is passed to the C side on the stack,
you use lua_ref (or is it luaL_ref in 5.0?) to stick it into the
registry, referred to by a unique integer. When you want to do the
callback, use lua_getref to retrieve the function. and pcall it like
normal.

This technique is also useful for other Lua-side-only types, such as tables.

Ben