lua-users home
lua-l archive

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


Am 24.11.2015 um 18:20 schröbte Viacheslav Usov:
On Tue, Nov 24, 2015 at 5:48 PM, Philipp Janda <siffiejoe@gmx.net> wrote:

This case should be handled in all libraries.

Sure. The question is, is that really the case?

No, it's definitely not the case :-)


Adding ref counting wouldn't unbreak the currently broken libraries.

The goal is not to unbreak. It is to keep those broken libs that manage to
work in the hands of their users, working.

And adding ref counting might break existing code: a simple
`lua_replace()` can now run finalizers and thus raise errors and cause
leaks in the C code.

I do not think I understand this part. Why would ref counting +
lua_replace() run finalizers?

`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.


Cheers,
V.


Philipp