[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Replacing setfenv() in lua 5.2?
- From: "D. Matt Placek" <atomicsuntan@...>
- Date: Tue, 23 Oct 2012 11:25:29 -0400
I'm trying to update a codebase from 5.1 to 5.2, and I'm wondering what to do with uses of setfenv(). I have code like:
chunk = loadfile( filename )
setfenv( chunk, envtable )
I don't see a way to replace the _ENV table for the loaded chunk unless _ENV is specifically declared in the source of the file I'm loading. Is there something obvious I'm missing? I don't like the idea of having to go into every file that could possibly be loaded and adding hooks to replace the local environment. Could I maybe change _ENV using debug.setupvalue, or is there a different mechanism that is recommended for replacing the old setfenv() calls?