[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua from C
- From: Thomas Jericke <tjericke@...>
- Date: Wed, 17 Dec 2014 13:20:47 +0100
On 12/17/2014 01:12 PM, Lev wrote:
Globals are not stored on the stack and therefore lua_settop(L, 0) won't
clean any globals.
Calling lua_settop(L, 0) after running a script only removes any results
returned by the previous script.
If you don't return any results from the scripts you can simply ignore
them by setting nresults of lua_pcall to zero.
On Wed, 17 Dec 2014 12:39:21 +0100
Thomas Jericke <firstname.lastname@example.org> wrote:
Depends on the usecase. Normally I would call luaL_newstate only once.
And then run all the scripts in the same state. Now there is one
issue here, if your scripts use globals you need to ensure that you
don't have any conflicts.
Thanks for the answer. Yes, I set global variables each time I call my
scripts. Shall I call lua_settop(L, 0) before any stack operation, and then
let the garbage collector do the right thing?