lua-users home
lua-l archive

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


It was thus said that the Great Phil Leblanc once stated:
> When os.exit() is called, by default the finalizer for <close>
> variables is not executed. If the second (optional) argument to
> os.exit() is true, then the Lua state is closed, and finalizers are
> executed.
> 
>   local x <close>
>   ...
>   os.exit(1)  -- x finalizer is not called
>   os.exit(1, true) -- x finalizer is called
> 
> I suggest to change the default for the second exit() argument so that
> the default be to call finalizers upon exit.

  The reason for the behavior is to remain compatible with Lua 5.1.  The
calls:

	os.exit(1)
	os.exit(1,nil)
	os.exit(1,false)

are the same, because nil and false are "falsy values" in Lua (all else is
true).  I can see the reasoning behind making the finalizers always called
on exit(), but it will result in different behavior between Lua 5.1 (which
is still widely used) and 5.2+.

  Besides, I think using 'true' to signify NOT to do something is, to me,
counterintuitive.

  -spc