lua-users home
lua-l archive

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


Francisco,

The idea that every object reference must be assigned a slot that lasts until the end of a block/call is not required anywhere outside of the C interface of the PUC Lua implementation, you're making unwarranted assumptions about how things should work.

An object reference may be abandoned as soon as the program gets to the point where it will no longer need the object for its normal execution (i.e. ignoring the effects of weak references and finalizers). The finalizer can run any time after that (1ns or 1 year later).

Using finalizers to modify the state of your program outside of the object that became unreachable is going to end in tears, unless you are very careful, you end up with a program whose behavior will be difficult to analyze because the finalizer can run at almost any point in your program, not just at statement boundaries.