lua-users home
lua-l archive

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

Florian Weimer <> 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.

f.anthony.n.finch  <>
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.