[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: local keyword in the global scope, and other things.
- From: "Aaron Brown" <arundelo@...>
- Date: Tue, 7 Nov 2006 22:08:27 -0500
Simon Wittber wrote:
I have a few questions :-)
What is the purpose of using the local keyword in the
There is no such thing, but I assume you mean a local at the
"top level" of a chunk, outside any function, like foo and
the second baz in the following example. (A file is an
example of a chunk.)
-- Beginning of file.
local bar = baz -- This use of baz is a global.
-- End of file.
Here are some properties of this type of local that
distinguish it from a global:
- It is not visible outside its chunk.
- It is only visible below its declaration. (This is why
fun doesn't see the local baz in the above example.)
- It is a bit faster than a global (because locals are
resolved at compile time and globals at runtime).