lua-users home
lua-l archive

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

On Wed, 28 Sept 2022 at 07:39, bil til <> wrote:
> I also think this requirement of writing <close> is somehow too much
> for the typical Lua user I think off.
> Lua is intended usually to be "simple programmable".

I'll settle for simple things simple, complex thing possible.

> And then it really would be much better, if the __close metafunction
> is used automatically (if it exists).

You have one of these, it is called __gc.

But you want it called ASAP, this is difficult to do on a garbage
generating resource management style.

I normally have an idempotent close()/destroy() method which leaves
the objects in an state where the object memory is the only resource
held, alias that as __close and __gc and, if the program tolerates it,
do frequent GC cycles. Not optimal, but I manage to process things
timely and without fail.

Francisco Olarte.