Hi, looking for some thoughts on loading DSL style data.
I have it working but would like to swap out the environment when doing so, so it doesn't trample on the global environment.
function load(name)
local env = getfenv(0)
setfenv(0, dsl)
local data = "">
setfenv(0, env)
end
Where I get the thread's environment, set the dsl table (with all the DSL functions) as the environment, load the data (using require), then restore the environment (presumably the _G table). Of course I should really pcall the load instead of require, and return the data, but that's the idea.
This is using Lua 5.1.5. I understand that Lua 5.2 changes the way environments are handled?
If anyone could offer tips here or even better, point to a page which explains a lot of this in this context, that would be super great.
Thanks,
Marc