[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: <close> and os.exit()
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sat, 30 May 2020 15:51:31 -0300
> This may have been an oversight on the Lua team, but as they have always
> stated, the lua exectuable has *always* been an example of how to embed Lua.
> And on most modern systems (POSIX definitely, possibly Windows these days),
> the operating system will reclaim any resources used by a process upon
> shutdown *anyway*.
>
> This was rectified with Lua 5.2, but to remain compatible with Lua 5.1
> code, they decided to add a parameter to os.exit() to indicate a clean
> closing of the Lua state, so the function now looks like:
>
> [...]
>
> Why they decided to keep this level of backwards compatability when they
> drastically changed how modules and global variables work between 5.1 and
> 5.2 is beyond me, especially when a workaround for Lua 5.1 (as illustrated
> above) was available.
I don't think the chosen default was to keep compatibility. As you
stated, several (most?) OSs already clear everything when a process
finishes, so there is no need to waste time clearing everything manually
when the script ends. Moreover, closing a state also frees all its
memory, which is another dubious (and often large) expense. So,
the default was to just finish the program and let the OS do all the
cleaning.
-- Roberto