lua-users home
lua-l archive

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


> Think the OP was thinking of a ???union??? model where lookups searched down the stack for the first match. But even in this case there is no need for any new keywords, as it???s easy to create the stack using a metatable on the _ENV table.

Sure. Just replace
	local _ENV={print=print}
with
	local _ENV=setmetatable({print=print},{__index=_ENV})

If you want a little sugar, you can do this

	local function push(t,e)
		return setmetatable(t,{__index=e})
	end
	...
	local _ENV=push({print=print},_ENV)