[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Recipe: setfenv with Lua 5.2.0 work3
- From: Pierre-Yves Gérardy <pygy79@...>
- Date: Thu, 20 May 2010 23:21:03 +0200
On Thu, May 20, 2010 at 18:15, Roberto Ierusalimschy <firstname.lastname@example.org>
result of load) then _ENV is always the first (and only) upvalue and it
Not necessarily. If the function is a main function (that is, the direct
is always present. Other functions have _ENV just like any other upvalue.
For instance, consider the following code:
function foo ()
return a + b
In function foo, the first upvalue is 'a' and the second is '_ENV'.
Why isn't it always the first upvalue? It would make things easier if one wants to play with the environment...