lua-users home
lua-l archive

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


On 11-Jan-07, at 6:14 PM, Matthew Armstrong wrote:

Is it possible to get an environment with local variables present too?

I'm trying:

function flarp()
    local myLocal = "hello"   
    local myEnv = getfenv()
    print(myEnv.myLocal) -- (prints nil)
end
flarp()


... but myEnv.myLocal is still nil.  Anyone know a way of doing this?  Or is it impossible?

You can only do it with the debug library, which is not recommended for production code (as well as being quite slow, and somewhat unreliable since it won't work if the compiled code has been stripped.)