lua-users home
lua-l archive

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


PH> So how does one now protect (as Gunnar wanted) submodules against accessing
PH> the standard globals? This sounds like a *big* change from Lua4.

currently I create the new environment by copying(*) the current global
environment. This scheme would have to be extended to set the global
tables for all functions copied to the new global table for the time
protected function is active, and them reset them to their previous
values afterwards. I think special care would need to be taken for
functions who already have their own global table. This is tedious,
and involves a lot of table traversing, but it should work.

(*)= copying instead of using __index also protects the methods stored
in a table from changes

Gunnar