lua-users home
lua-l archive

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


On Mon, 17 Jun 2019 at 05:11, Aapo Talvensaari
<aapo.talvensaari@gmail.com> wrote:
>
> On Wed, Jun 12, 2019 at 3:46 PM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>>
>> > Right now, my only complain with the <toclose> is the term "close" that I
>> > found a bit vague and over-loaded (conceptually).
>>
>> Suggestions are welcome.
>
>
> Name aside, what about something similar to:
> http://luajit.org/ext_ffi_api.html#ffi_gc

The behavior of ffi.gc is analogous to Lua's already-existing __gc metamethod.

> E.g.
>
> local f = toclose(io.open("myfile"), function(f)
>   f:close()
> end)
> io.close(toclose(f, nil))

This is not an option because the to-close behavior in Lua 5.4 is
relative to the variable, not the value.

-- Hisham