As an alternative option, you can change the namespace from the outside,
when you load a "module":
local f = loadfile(filename)
local new_namespace = {...}
setglobals(f, new_namespace)
f() -- run the chunk
I like this form because modules can be written without regard to a
namespace, Python-style.
Somehow, over the original plan, you managed to make the globals system
easier to comprehend and more dynamic at the same time. It really
changes everything.