On Tue, Nov 24, 2015 at 10:48 AM, Philipp Janda <siffiejoe@gmx.net> wrote:
Am 24.11.2015 um 18:51 schröbte Viacheslav Usov:
On Tue, Nov 24, 2015 at 6:34 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
`lua_replace` overwrites a stack slot. If that stack slot contained the
last reference to a value, that value has to be finalized. The same
applies
to `lua_pop`, `lua_remove`, `lua_copy`, `lua_xmove`, `lua_rawget`,
`lua_next`, etc.
It is not the slots that should have ref counts. Slots stay what they are.
It is the objects (userdata and tables) that should have ref counts
I'm not sure I can follow. When would you update the reference counts?
When the object is assigned to a stack slot, when it's removed from a
stack slot, when it's assigned to a table field, when it's removed
from a table field, when it's assigned to a table key, when it's used
as a key to store nil into a table, when a table that contains it is
destroyed. The exceptions are weak tables, where being assigned as a
weak key/value does not modify the refcount (but has to track a
backpointer to clean it up).