lua-users home
lua-l archive

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


On Mon, Nov 23, 2015 at 8:38 PM, Coda Highland <chighland@gmail.com> wrote:

> I think that we're actually looking at an XY issue here.

> Deterministic finalization is a means to a particular end, but what is that desired end? Ultimately: We want a specific function to be called when control exits a block, no matter how it exits.

At the lowest level of abstraction, one could say that. But I do not like the idea that Lua programs need to be using lowest levels of abstraction and micromanagement that comes with that.

If we forget, for a second, "external" resources. such as files, then Lua's internal resources (memory) are managed automatically. The user does not have to deal with that at all, at least in principle. Why should that be different for external resources? The only reason the user has to be involved now is because the language does not provide any means of deterministic finalization to library writers. If we decorate Lua with additional low level means of resource management, they should primarily be means available to library writers; we should not make the user even MORE involved.

On the other hand, if those new means require library writers to follow some new paradigm, then we cannot expect they will be universally adopted. We will have a mess not unlike what C++ is, with its multiple resource management paradigms. The proposed reference counting mechanism ensures that neither users nor library writers need to do anything new. We just improve the behaviour of all the existing code, and let users write simpler yet more efficient code in future.

Cheers,
V.