I have some lua code in a file. I want to create multiple closure instances of this code, each with a different \_ENV upvalue. I can use [luaL\_loadfile](http://www.lua.org/manual/5.2/manual.html#luaL_loadfile) to load the file and set the first upvalue, N times with different tables, to create N instances. But wouldn't this load and compile the file N times?

The lua equivalent of what i want to do is the following, except without the loadfile

```
func_list = {}

for i = 1, 10 do
    local new_env = {hello=i, print=print}
    func_list[i] = loadfile("Code.lua", "t", new_env)
end

for i = 1, 10 do
    func_list[i]()
end

------ Code.lua ------
print(hello*hello)

```

is there a better way to do this?