lua-users home
lua-l archive

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

> The scope of a local variable is the part of the smallest chunk
> containing its declaration which follows it.

The manual does not bring chunks into the definition of scope.
It says:

   The scope of variables begins at the first statement
   after their declaration and lasts until the end of
   the innermost block that includes the declaration.

Is the quoted definition equivalent to that?  Hardly.

The "smallest chunk containing its declaration" of a variable
is just the declaration.  The part of it that follows the
declaration is empty.  It's useless, but it is a chunk.

An example, showing that those are chunks.

   f=load"local y=x"; print(f)
   f=load""; print(f)

In both cases, f is a perfectly respectable function,
the execution which returns nothing and has no side effects.