[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Recipe: setfenv with Lua 5.2.0 work3
- From: David Manura <dm.lua@...>
- Date: Sat, 12 Jun 2010 18:49:24 -0400
2010/5/20 Pierre-Yves Gérardy <email@example.com>:
> On Thu, May 20, 2010 at 18:15, Roberto Ierusalimschy wrote:
>> local a function foo () return a + b end
>> 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...
If you change "a + b" to "b + a", the upvalues get reversed. The
implementation appears to order upvalues in the order in which they
are used, not the order in which they are defined.