[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: block-scope finalization
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 25 Nov 2015 09:20:22 -0200
> Lua already does that when closing upvalues, in luaF_close. This
> proposal would probably be implemented by expanding luaF_close's
> purpose to also call the __close metamethod on these new types of
> locals. Fortunately a lot of the work for closing upvalues overlaps
> here.
Exactly. A "local <new name>" will create an upvalue just like a closure,
but with an extra bit telling "I need finalization". Then, luaF_close
checks that bit when closing upvalues and call the appropriate functions
when needed. (The implementation would be trivial; what makes things
more complex is handling errors inside those functions.)
-- Roberto
- References:
- Re: block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Javier Guerra Giraldez
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Patrick Donnelly
- Re: block-scope finalization, Roberto Ierusalimschy
- Re: block-scope finalization, Dibyendu Majumdar
- Re: block-scope finalization, Coda Highland
- Re: block-scope finalization, Dibyendu Majumdar
- Re: block-scope finalization, Patrick Donnelly