lua-users home
lua-l archive

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


I'm on a tool that load then execute several Lua scripts so I have many call to luaL_loadfile()/lua_pcall() pairs. My question is about code persistence.

3 examples :

--- script1.lua ---
print "I'm doing very interesting stuffs"

--- script2.lua ---
function toto()
   print "even more interesting stuffs"

--- script3.lua ---
print "Yeah, I'm here"

function tata()
  print "I'm the most interesting one"

My assertions are the following :

1/ content of script1 is only one shot so it is collected and resource are freed
2/ toto() and tata() kept, ready to be called by other code.
3/ after loading/calling all those 3 script, in Lua's memory only toto() and tata() remain, and "external" prints get collected after execution.

Am I right ?