lua-users home
lua-l archive

Re: [ANN] Lua 5.4.0 (alpha-rc2) now available

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


On 2019年6月17日 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

AltStyle によって変換されたページ (->オリジナル) /