lua-users home
lua-l archive

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


On Tue, Jul 13, 2004 at 02:19:34PM +0200, Enno Rehling wrote:
> I am loading a bunch of user-scripts from a list of files, and I'm 
> wondering how to keep them from messing with each other. If I have two 
> scripts defining the same identifier in the globals table (like two 
> functions called action(), or two variables called size), One of those 
> scripts is going to puke.

If they are user-scripts you may want to check for name collision using 
the __index or __newindex metamethods (and avoid global overwrites)

you may also hack a bit with setfenv (see PIL chapter 14) that is
probably the good way of protecting the _G environment from usr scripts.
-- 
Enrico Tassi