[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A question on the definition of a chunk
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 27 Jun 2012 11:32:15 +0200
2012/6/27 Michal Kottman <firstname.lastname@example.org>:
> On 27 June 2012 08:58, Alexander R. <email@example.com> 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?
> Each "thing" you compile using the "load" family of functions - i.e.
> luaL_loadbuffer, luaL_loadstring, luaL_loadfile from the C API and
> load, loadfile, loadstring from the Lua API - is understood as a
> "chunk" and is compiled as if it were a function (without the
> "function (...)" header).
Way I see it, a character string `P` is a chunk if and only if the first
return value of
is not nil, otherwise `P` is garbage. Whether it is just one statement
or a 5000-line program. ("garbage" and "chunk" may differ by only one
character.) (It is `load(P)` in 5.2 but for the moment `loadstring`