[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Down with Upvalues
- From: Roberto Ierusalimschy <rieru@...>
- Date: Fri, 31 Aug 2001 14:35:47 -0500 (CDT)
On Fri, 31 Aug 2001, Russell Y. Webb wrote:
> In any case, it would be useful to know if basically we all agree on what
> would be ideal aside from how it could be accomplished or what compromises
> it entails.
I guess the ideal is simply "full (complete? unrestricted? ''?) lexical
(statically? non-dynamic?) visibility (scoping?)". That is, any function
can access (read and write) any variable that is visible at the point where
the function is defined.
(Of course there are some subtleties; the static denotation of a variable
may denote multiple instances of that variable when we have loops. For
instance, in the next fragment
local a = {}
local l1
for i=1,N do
local l2 = i
a[i] = function (x) l2 = l1/x; l1 = x; return l1+l2 end
end
local s = 0
for i=1,N do
s = s+a[i](i)
end
all functions share one variable l1, but each uses a different l2. When
we add to this multiple levels, things get a little more complex. But
the general idea is simple...)
The problem is how to implement it in Lua, without compromising Lua speed
and size. We are working on a solution that seems promissing; there is a
good chance that Lua 4.1 will meet the above "ideal".
-- Roberto