lua-users home
lua-l archive

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


Carsten Fuchs wrote:
> Is it sufficient to set the variable that holds the function to nil?
> The problem is that if someone makes a copy of the variable 
> with the function, and continues to use the copy to call the 
> function after the DLL has been unloaded, I expect to get a 
> bad crash... Is there anything I can do to prevent this kind 
> of scenario?

I think you're right about the potential crash. You can encapsulate your
function in a userdata with a __call metamethod. And then when the
function is called after the dll is unloaded you have to make sure your
__call function can detect it and raise an error. However this means
that your __call function is never unloaded, and whether it's feasible
depends on your dll loader/unloader.