[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Transaction Oriented GC algorithm in GoLang
- From: Patrick Donnelly <batrick@...>
- Date: Sat, 25 Jun 2016 11:47:18 -0400
On Fri, Jun 24, 2016 at 6:45 PM, Javier Guerra Giraldez
<javier@guerrag.com> wrote:
> (i'm quite rusty with pcall(), but i think the intention is clear...)
> of course, it would be a _lot_ better to avoid the function creation,
> and instead have some language support to hook resource release
> directly to scope exit:
>
> do
> local f = open(...)
> onexit do f:close() end
> .... do things with f ....
> end
>
>
> and having the block in the onexit do .... end execute on any exit
> from the surrounding block. of course, it should be possible to add
> several onexit do...end clauses. a bit like go's 'defer' keyword
> (which is an example of non-RAII for a garbage-collected language,
> albeit an static one)
For other readers, this has also been extensively discussed in this
thread [1]. In particular, see Roberto's proposal [2].
[1] http://lua-users.org/lists/lua-l/2015-11/msg00152.html
[2] http://lua-users.org/lists/lua-l/2015-11/msg00303.html
--
Patrick Donnelly