lua-users home
lua-l archive

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


Hi!

To-be-closed variables were introduced as a more strict (and preferred) mechanism than GC finalizers.
But in suspended and normal coroutines the __close metamethods does not run on program exit!

If a coroutine is created with coroutine.create,
we need to not forget to invoke coroutine.close somewhere before the program exits.
And if a coroutine is created with coroutine.wrap,
we don't even have the ability to invoke coroutine.close!
As a result, we have to duplicate all __close functionality in finalizers.
Why such inconvenience?

To-be-closed variables should be reliable and self-sufficient.
The suggestion:
When VM is closing, coroutine.close() should be automatically invoked for every non-dead coroutine in the VM.
This way we could forget about __gc and work only with __close.