[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Questioning variable scoping in Lua
- From: "Ben Aurel" <ben.aurel@...>
- Date: Tue, 20 Jan 2009 12:27:16 +0100
Because I'm new to Lua I'm going through some cool Lua projects (lqt,
nanoki,...) in order to see how the language is used in real world
Even if you just look at the source from a distance, not necessarily
trying to understand what the code actualy does, you notice the
excessive use of the "local" keyword.
- Setting the default scope to "global" why is that really usefull? I
think most of the time, you try to avoid global state. Why not the
default scope to "global"? Wouldn't that reduce a lot of typing?
- What if the developer forgets a "local"? The program runs anyway,
but there is a chance that there is some unwanted behavior that is
hard to trace.
I think I miss something here. Could somebody explain me the reason
behind the design decision?
thanks a lot