lua-users home
lua-l archive

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


> local scope = {}
> setfenv(function()
>        foo = 1
>        bar = 2
> end, scope)()
> assert(foo == nil)
> assert(bar == nil)
> assert(scope.foo == 1)
> assert(scope.bar == 2)

Guess the big idea is to setfenv() a function without affecting its
semantics on other parts of the code outside of your in do end. Can't
do this in 5.1, and it's the reason I reserved the use of setfenv()
only for implementing module stuff [1].

[1] http://code.google.com/p/fbclient/source/browse/fbclient/package.lua