[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: block-scope finalization
- From: Patrick Donnelly <batrick@...>
- Date: Tue, 24 Nov 2015 09:27:29 -0500
On Tue, Nov 24, 2015 at 4:50 AM, Viacheslav Usov <via.usov@gmail.com> wrote:
> On Tue, Nov 24, 2015 at 3:10 AM, Patrick Donnelly <batrick@batbytes.com>
> wrote:
>
>> For Lua, we can simply annotate the local variable to indicate its value
>> should be cleaned up when the local scope ends.
>
> This is exactly what I proposed originally. But after a week of thinking my
> conclusion is that this is too weird, because it breaks a major assumption,
> See the details in my earlier message and the subsequent exchange with
> Roberto.
Sorry, one more message to respond to the "breaks a major assumption":
are you talking about the issue of calling __gc more than once on an
object? Or perhaps a block "hijacking" an object to close?
function a(foo)
block bar = foo
-- haha! I'm tricking Lua into calling getmetatable(foo).__gc(foo)
end
function b()
local bar = io.open("file")
a(bar)
end
I don't see this as a real issue because a could have simply called foo:close().
--
Patrick Donnelly
- References:
- block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Soni L.
- Re: block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Philipp Janda
- Re: block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Philipp Janda
- Re: block-scope finalization, Viacheslav Usov
- Re: block-scope finalization, Philipp Janda
- Re: block-scope finalization, Philipp Janda
- 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, Viacheslav Usov