lua-users home
lua-l archive

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

In message <> you wrote:

> On Wednesday, June 27, 2012 02:58:26 AM Alexander R. wrote:
> > I'm afraid it's a language problem as my English is not perfect, but do
> > I get this right: A chunk in Lua is everything, each piece of code that
> > gets executed by Lua is called so, no matter if it's a 50-line-function
> > or a single association, et cetera?

This turns on what you mean by "piece of code" and "executed". As the
manual says, function definitions, looping structures, do ... end
structures and separate files of Lua source code constitute chunks.
Chunks contain sequences of statements or chunks. The notion of
subchunk, i.e. one chunk contained in another, is the salient concept
to be grasped, IMHO. Chunks form an ordered tree (in the mathematical sense
of that phrase) with root the chunk consisting of the whole program. 
The scope of a local variable is the part of the smallest chunk containing 
its declaration which follows it.
Gavin Wraith (
Home page: