Lua_icxx
1.02 (Aug 2011)
|
The function environment is useful to create a "sandbox" for the function body, ie to control which parts of Lua the function code has access to -- critical for preventing bad script behavior.
The table given as sandbox provides the global environment of the function. Hence if the table contains only one field, "print", the associated value of which is a reference to Lua's print function, then the function code will only be able to call print and nothing else. Note that due to Lua's mechanism of "tables as classes", ie tables can "derive" from another table, functions can have sandboxes that consist of a shared part and a part specific to only the function.