lua-users home
lua-l archive

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


On Thu, 30 Jul 2020 at 18:01, Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
>
>
>> The suggestion:
>> When VM is closing, coroutine.close() should be automatically invoked for every non-dead coroutine in the VM.
>
>
> Dead coroutines (after an error is raised) can have non-closed to-be-closed variables too.
> So, the suggestion is: All coroutines in the VM should be implicitly closed on VM exit.
> Of course it would be better to implicitly close dead coroutines at the moment they become dead.

Repeating myself - the 'defer' statement leads to no such issue or
expectation - as it is explicitly related to a scope exit and does not
promise to close anything!

In my opinion it is perfectly correct that the close method is not
invoked unless scope is exited. You just need to ensure that the close
logic is also invoked by the GC, which will presumably cleanup
everything eventually.