lua-users home
lua-l archive

[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