[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Auto-closing with loops
- From: Tom N Harris <telliamed@...>
- Date: Fri, 20 Jul 2018 22:52:14 -0400
On Friday, July 20, 2018 04:55:49 PM pocomane wrote:
> It is not difficult to implement in lua a couple of functions that let
> you to write:
>
> ```
> local sequence = 'start'
>
> barrier(function() -- Protect code region
> local a = {}
>
> setfinalizer(a, function(x) -- Call on scope exit
> assert(a == x)
> sequence = sequence .. '; closing a'
> end)
>
> sequence = sequence .. '; using a'
> error('an error')
> end)
>
> assert(sequence == 'start; using a; closing a')
> ```
This thread gives me a great sense of déjà vu.
http://lua-users.org/lists/lua-l/2015-11/msg00164.html
--
tom <telliamed@whoopdedo.org>