|
On 30/05/2020 18:19, Javier Guerra Giraldez wrote:
This is understandable, but you seem to see only the perspective of Lua as embedded in a host application.for me, it's `os.exit()`, does exactly what i'd expect: tell the OS to kill the host program. it's not a normal, clean shutdown; it's an immediate, last-resort kill. anything else has to be asked specifically. having a convenient, optional "try to close the interpreter" capability is nice, but i'd rather not use it frequently; much better is to ask the host program to close itself (and the Lua state(s)) orderly.
I write essentially Lua programs as scripts for the standard interpreter, and I resort to C only rarely, and always to make some OS facility available to Lua scripts.
In this case the host application is the Lua interpreter, and there is no other way to ask it to exit nicely.
As I argued in another post, replying to Sean, __close & C. is a new, clean way to do RAII, but it is somewhat in contrast with default os.exit behavior.
Funnily enough, os.exit, by default, does less than what C exit function guarantees, i.e. equivalent to returning from main (C has much uglier looking alternatives for emergency exit).
Cheers! -- Lorenzo