lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Sony:

On Fri, Jun 21, 2019 at 10:42 PM Soni "They/Them" L. <fakedme@gmail.com> wrote:
...
> I'm convinced <toclose> should support nested contexts (read: have an
> __enter).

Do you realize you can do "local <toclose> x = ctx.__enter()" ( and
have enter return either self or a helper object )

I think the behaviour is enough, mechanism, you cannot do the
equivalent of <toclose>, but enter is trivial and in fact there are
things like Java which are dessigned to work this way ( try with
resources, which is very similar to <toclose> ).

> I have, many times, used file:lines() (which is more like
> file:read_iter() because you can give it args) in a loop that I would
> break out of, and then I'd use the file some more.

Then do it, it is simple. do, local toclose = file.open, for loop with
may break , some things wihich happen after it, end. No need for enter
anywhere.

Francisco Olarte.