[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: upvals in Lua bytecode
- From: Tony Finch <dot@...>
- Date: Thu, 2 Jun 2011 12:10:03 +0100
Florian Weimer <fw@deneb.enyo.de> wrote:
>
> Anyway, to me, the local-vs-global discussion is tied to the module
> system and some sort of phase distinction in the compiler. If there
> was a way to plug into global name lookup in the compiler, we could
> accurately describe to the compiler what global variables exist, and
> the compiler could error out for unknown global variables.
I think this is over-ambitious. You can get a lot of benefit from just
checking that variables are declared before use within a module. It then
becomes easy to find which global variables exist using grep - though it
gets interesting if you play games with function environments.
> It might even be possible to compile expressions such as string.byte to
> a constant reference in the byte code, so that the need for the "local
> byte = string.byte" pattern goes away.
LuaJIT does that, but it requires analysis to prove that string.byte is
not assigned to directly or via an alias.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
Rockall, Malin, Hebrides: South 5 to 7, occasionally gale 8 at first in
Rockall and Malin, veering west or northwest 4 or 5, then backing southwest 5
or 6 later. Rough or very rough. Occasional rain. Moderate or good,
occasionally poor.