lua-users home
lua-l archive

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




On Tue, Sep 27, 2022 at 10:39 PM bil til <biltil52@gmail.com> 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".

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

Automatic '__close' calling makes it impossible to return the value from a function, so you'd need an exception for that case. Alternatively you may want to store a reference in a table and NOT call __close at times. The Lua interpreter would have to use some rule to determine whether the value stored in a local variable 'escapes' the function. This rule would have to correctly guess the intent of the programmer. I suspect that the edge cases caused by that rule would utterly confuse your "typical Lua user". I prefer to keep things predictable and write <close>.



--