lua-users home
lua-l archive

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


Fabio,

> There is a bug in the __tostring metamethod for libraries, that is why
> you are seeing garbage, sorry. BTW, you need to set lib=nil in your
> code or you won't get collect the second library, and you need to call
> collectgarbage twice to collect them, because of the finalizer.

You're right. Two gc passes and unbinding the local. Unloading works
now. Thanks.

I think I found the problem with second issue. All loaded libraries
share the same metatable, the global ALIEN_LIBRARY_META, of which
__index = a closure with one upvalue, which is a table in which every
function is cached by name only. So to solve the problem, either cache
functions by libname.funcname or let each library have its own
metatable inheriting from ALIEN_LIBRARY_META, and change
alien_checklibrary() accordingly.

Cosmin.