lua-users home
lua-l archive

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


> The upvalue will not be collected. However it may be replaced with
> debug.setupvalue. On one hand you can protect your code by adding a
> check, so that debug.setupvalue make your function unusable. On the
> other hand if debug.setupvalue is available to the user, he may have
> valid reason to use it on your function, and it may be nicer to avoid
> checking for your upvalues.
>
> I'd choose the second option, let the user put anything he wants in
> the upvalues, and just use the value as usual, letting regular errors
> (like indexing a nil value) propagate. In your lua_touserdata case,
> just check the return value for NULL, and eventually throw an error
> (or implement a fallback behavior if one is possible).
>

Thank you, Jerome!!
That's very helpful.

I guess, I'll leave debug things for special debug build.