lua-users home
lua-l archive

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


On 25/01/2013 18:50, Luiz Henrique de Figueiredo wrote:

> It only sets the first upvalue if there is exactly one upvalue, which is
> the case for main chunks.
> 

So... _ENV is not an implicit upvalue of every function?
If it was, the original example would have had two upvalues instead of
one, and so its 'x' would not have been bound to _ENV but would have
defaulted to nil instead.  Is that correct?

> function ffactory(x) return function() return x end end
> f1 = ffactory(5)

And if you could write a main chunk that did not reference _ENV, would
it then have zero upvalues?