lua-users home
lua-l archive

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


> Because Lua supports proper lexical scoping and nested closures so
> thoroughly (as opposed to, e.g., Python), default local would be untenable.
> The most sensible and simplest rule is what Lua uses, IMO.

I use a simple metatable modification to catch assignments to global
variables whose names match a certain pattern, currently "^%a%d?$".
I.e. names like `i` or `a1` will trigger a warning. Not foolproof of
course, but I try to follow the rule that anything I genuinely want
in `global` must have a nume that does not math that format.