lua-users home
lua-l archive

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


Quoth Udo Schroeter:
> I was on a similar quest, but ended up doing it very differently. In my
> personal dialect, I have disallowed the incidental declaration of global
> variables. Declarations are all local/lexical and assigning a value to an
> undeclared variable is a runtime error. Combined with things that make some
> nil checks superfluous, I'm quite happy with the result.

Why create a Lua dialect for this? In Lua 5.2 and up, you can do this
more simply by creating a new metatable for _G and setting its
__newindex to raise an error.