lua-users home
lua-l archive

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


Sorry, the top six lines were not copied.
I'm appending the file.

id="_ENV as in original registry"
local load,print = load,print
local orig_ENV = _ENV
print(_ENV,id)

do
id="_ENV as in original registry"
local load,print = load,print
local orig_ENV = _ENV
print(_ENV,id)

do
local _ENV = {id="_ENV local to `do` block"}

local function f1() return _ENV, id end
print("case c:",f1())
local _ENV1=_ENV
_ENV = {id="_ENV shadowing previous local variable"}
print("case c:",f1())
print "case c: _ENV is the table currently in this upvalue"
local function f2(_ENV) return _ENV, id end
print("case a:",f2(_ENV1))
print("case a:",f2(_ENV))
print "case a: _ENV is the table passed as argument to the function"
local f3 = load("return _ENV,id",nil,nil,_ENV1)
print("case b:",f3())
local f3 = load("return _ENV,id",nil,nil,_ENV)
print("case b:",f3())
print "case b: _ENV is the table passed as argument to load"
end