[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: using 'return' to halt an executable Lua script
- From: Andrew Gierth <andrew@...>
- Date: Sat, 15 Sep 2018 00:04:05 +0100
>>>>> "Joseph" == Joseph Manning <manning@cs.ucc.ie> writes:
Joseph> The alternative is, of course, to use 'os.exit( )' -- but in
Joseph> the above context, does using 'return' basically achieve the
Joseph> same effect?
os.exit() doesn't close the Lua state before exiting, whereas returning
from the invoked chunk does.
$ lua53 -e 't = setmetatable({},{__gc=function() print "foo" end})'
foo
$
$ lua53 -e 't = setmetatable({},{__gc=function() print "foo" end}) os.exit(0)'
$
--
Andrew.