lua-users home
lua-l archive

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


Each function definition in Lua forms a chunk when compiled and any code in a script that is not in a function forms the main chunk. 
 
Would you for instance say that when you type in something
in an interactive session, and hit return, and Lua executes it,
those statements formed a chunk?

I'd imagine so, yes. I notice that local vars are only in scope within a single input, which suggests that they are compiled and executed as if they are in a self-executing anonymous function.

And in that case, should not a literal reading of the sentence
I quoted imply that the first line you type in is allowed to start
with a hash?

In theory, yes. However, in practice this is not true for the interpreter or for functions. The manual should probably read "script" as you suggest, or at least "the main chunk."