lua-users home
lua-l archive

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


On Mon, Aug 24, 2020 at 8:46 PM bel <bel2125@gmail.com> wrote:

> What would be the appropriate way to implement a "luaclose_mylib" function in C, that would work as an inverse of "luaopen_mylib"?

Have you considered that your library might be used by a process with
multiple Lua states, which come and go dynamically in parallel
threads?

My advice is NOT to have any global state in a library. Instead, all
the state should be linked to the object that the require function
returns. Doing otherwise is a source of persistent problems,
especially in the scenario above.

Cheers,
V.