[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Making Lua lexically scoped (was: Re: Proper tail recursion)
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 30 Jul 2001 11:38:08 -0300
Another way to implement (true? proper?) lexical scoping in Lua is to keep
all variables in the stack while running the function. When it returns, if
the function has "children" (that is, nested functions with access to its
variables), then we copy its activation record (or part of it) to the heap,
and somehow correct the pointers in the nested functions (for instance,
we can keep all functions created by it in a linked list).
One thing we need to change to implement that is that each local variable
should have an exclusive register for it. (Currently, variables have a
register only when they are alive. Outside that, registers are reused for
temporaries or other variables.) This is not difficult to change.
The handling of errors (when a function ends without returning) is still
a problem...
-- Roberto