[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Protecting global variables
- From: Enrico Colombini <erix@...>
- Date: Thu, 16 Aug 2012 14:59:11 +0200
Peter, assuming I understood correctly what you want to do, you could
also consider a sandbox approach, rather than filtering _G access:
- Create a table that will be your user's global table. You could start
with an empty table, or include some globals:
userGlobal = { print=print, string=string, myvar=myvar }
- Attach a metatable to handle your special variables (as you already did).
- Execute user's code with that table as environment (using sefenv() in
Lua 5.1 or setting _ENV in Lua 5.2).
--
Enrico