lua-users home
lua-l archive

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


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?