lua-users home
lua-l archive

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


On 3/08/2010, at 7:12 PM, steve donovan wrote:

> On Tue, Aug 3, 2010 at 7:57 AM, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
>> Bytecode equivalence aside, couldn't you achieve this with:
>> 
>> local _ENV = setmetatable({}, { __index = _G})  -- or is that __index=_ENV now?
>> function foo() bar() end
>> function bar() print'!' end
>> return setmetatable(_ENV, nil)
> 
> This wouldn't work, because if M.bar() is called later, the
> environment will have been altered and print will not be resolved.

Oh yeah, good point.