[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Deprecating setfenv()
- From: Cosmin Apreutesei <cosmin.apreutesei@...>
- Date: Sun, 10 Jan 2010 01:20:26 +0200
> 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