lua-users home
lua-l archive

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


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?

The building blocks of Lua are functions. All functions can be referenced, 
where you cannot make a reference to an arbitrary statement. A chunk is just a 
specific type of function: one which is generated from a complete pass of the 
parser over an input source. (Not necessarily a file or string, since the 
load() function can accept a function as a source.)

The significance of a chunk, compared to a regular function, is that a chunk 
is not created in the context of another function. This is relevant to where 
global variables come from.

-- 
tom <telliamed@whoopdedo.org>