[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Local and Global Variables
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 24 Apr 2013 23:18:19 +0200
> 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.