Salve.__gc function is expected to be part of object's metatable, not the part of the object itself. So you should for example create table with your sole __gc function, and set it as metatable for your module (module is just a table? am i right? i am not familiar with packaging proposal, nor with compat library).
AMDG, Antero Vipunen. Vijay Aswadhati wrote:
Searching through the archives I found this post[1] that suggests a way to call
function on exit. How does it work in practice for a module. In other words if
I have code like this:
<C code>
static int z_foo(lua_State *L);
static int z_bar(lua_State *L);
static int z_initialize();
static int z_finalize();
static const struct luaL_reg functions[] = {
{"foo", z_foo},
{"bar", z_bar},
{"__gc", z_finalize}, /* <-- does not work */
{NULL, NULL}
};