[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors
- From: Francisco Olarte <folarte@...>
- Date: Tue, 25 Jun 2019 20:14:43 +0200
Sergey:
On Tue, Jun 25, 2019 at 7:49 PM Sergey Kovalev <kovserg33@gmail.com> wrote:
> Can this code solve auto close problem https://pastebin.com/LPxHKKp8
It can solve some problems, and introduce others ( one of them is lack
of doc for it, but I'll blame that on the situation, and it seems to
assume init/error/done and some more donot error, and gives you lot of
behaviour which may be adequate for a project but not for others ).
For a big project, writing one of these and sticking to it, may be
good. <toclose> can be used as a building block for that, and as the
final solution if appropiate, it's basically a try-with-resources,
useful for somethings, not so much for others, quite powerful, being a
built-in, if you shape your code to use it. And being a built-in it
has the potential to save you a lot of code compared to other
alternatives. It seems it could be totally emulated by using pcall
wisely, but it is simple to use and short.
The only thing I dislike is the propagation on all the line ( which I
thing has been pointed as leading to problems in some io.open examples
), and may be the constness ( which forbids me shutting down __close,
but this can be easily avoided with a mini class ) and optional
closing can easily be done by deferring <toclose> a bit, which can
also solve the io.open problem.
Francisco Olarte.
- References:
- Lua 5.4.0-alpha-rc1 behavior with closing methods errors, phlnc8
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, David Heiko Kolf
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Francisco Olarte
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, David Heiko Kolf
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Francisco Olarte
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, David Heiko Kolf
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Francisco Olarte
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Sergey Kovalev
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Matthew Wild
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Sergey Kovalev
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Francisco Olarte
- Re: Lua 5.4.0-alpha-rc1 behavior with closing methods errors, Sergey Kovalev