what's the difference between chunk and block in lua? I can not understand what is chunk!!!
A chunk is an independently executable sequence of statements. A block is just a sequence of statements. The difference is that a chunk can be executed independently of other chunks.
All chunks are blocks (sequences of statements), but not all blocks are chunks.
A chunk is basically a Lua function; you can call it with some parameters, and it will return 0 or more values. That's what I mean by "independently executable": the statements within a chunk will be executed in order. But once you exit a chunk, what chunk you execute next is up to you.
Has been asked and addressed here: http://lua-users.org/lists/lua-l/2012-06/threads.html#00723
From the 5.2 Manual:
The unit of execution of Lua is called a chunk. Syntactically, a chunk is simply a block:
chunk ::= block
From the mouth of Roberto:
The fact that a chunk is a block does not mean that any block is a chunk. Chunks do not nest (unlike blocks). A chunk is an outermost block which you feed to "load".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With