[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Yet another proposal for <toclose> (was Re: [ANN] Lua 5.4.0 (alpha) now available)
- From: Sergey Kovalev <kovserg33@...>
- Date: Sat, 29 Jun 2019 02:12:13 +0300
> The proposed 'defer' statement looks like this:
>
> defer ... end
>
> with the guarantee that f will be invoked at scope exit.
>
Can be done following way:
scope(function(auto) local defer=function(fn) auto(fn){true} end
defer(function() print "defer1" end)
defer(function() print "defer2" end)
end)
> 5) Variables may be captured as upvalues in the function too
Main problem of upvalues is: there is no effective way to isolate
function body from upvalues in lua.