lua-users home
lua-l archive

How to specify parameters to a file chunk?

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


Hi, All,
As we know, loadfile() read a lua file and build a function accordingly.
Can we give the function any parameters when invoking it?
for example:
-- chunk.lua
print(arg[1])
io.flush()
-- invoke.lua
local chunk = assert(loadfile("chunk.lua"))
chunk("123") -- print "nil" rather than "123"
Does it mean we cannot pass any parameters to generated function?
Thanks a lot and best regards,
Tsong Chong

AltStyle によって変換されたページ (->オリジナル) /