lua-users home
lua-l archive

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


> so that libraries could be unloaded manually or when the app closes.

To unload libraries manually seems quite dangerous. It is hard to know
(manually) for sure that there are no more functions that use the
library. One option is to add the handle as an upvalue in all functions
from that library. So, when the last function is collected, the handle
would be collected, too. (I think ET mentioned something like that
sometime ago.)  This works, but it adds some overhead on C functions.
And is the unloading of dynamic libraries during run-time really
necessary?

To unload the library when the app closes is much easier. We can simply
put the handle in the registry (with an appropriate GC metamethod).

-- Roberto