, , .
, , "" - , , , .
dofile, , , , -, . , "dofile" C/++, , , , .
, " , ". , , ', X' ', Y .
, , , , loadfile/dofile, -. lua " , () , () ". , .
, - , . , , .
, , , , - script , script, . , dofile . lua 5.1 vs lua 5.2.
lua 5.1:
a.lua
:
local shared = { x = 5 }
temp = loadfile('b.lua')
setfenv(temp, shared)
f = temp()
f()
lua 5.2:
a.lua
:
local shared = { x = 5 }
temp = loadfile('b.lua', 't', shared)
f = temp()
f()