[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: a new proposal for environments
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 26 Feb 2010 08:31:22 -0300
> As I understand, every Lua function will have at least one upvalue,
> _ENV. This would be slot 0 ?
Only the main function of a chunk will have a fixed, single upvalue _ENV
in slot 1. Other functions may or may not have an upvalue _ENV, which
may be in any position, as happens with any upvalue. (It is created on
demand by the compiler.)
I see two strategies for handling binary functions:
- If the function has one single upvalue called _ENV, 'load' will
initialize it with _G (similarly for 'loadin').
- If the function has any upvalue called _ENV, 'load' will initialize it
with _G (similarly for 'loadin').
(Actually, the strategy is the same for text functions, but in that
case the result will surely have just one upvalue, called _ENV.)
-- Roberto
- References:
- a new proposal for environments, Roberto Ierusalimschy
- Re: a new proposal for environments, Patrick Donnelly
- Re: a new proposal for environments, Roberto Ierusalimschy
- Re: a new proposal for environments, Patrick Donnelly
- Re: a new proposal for environments, Roberto Ierusalimschy
- Re: a new proposal for environments, froese
- Re: a new proposal for environments, Roberto Ierusalimschy
- Re: a new proposal for environments, Doug Currie
- Re: a new proposal for environments, Mark Hamburg
- Re: a new proposal for environments, steve donovan