[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Proposal?] Environment stacks
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sun, 30 Nov 2014 22:35:05 -0200
> 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)