lua-users home
lua-l archive

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


2012/2/1 Dirk Laurie <dirk.laurie@gmail.com>:
>
>> The reference manual could further explain that a label is allowed
>> just before a "end", even if there are local variables declared in the
>> block.
>> Also, the manual could show one or two examples for typical "continue"
>> or "redo" usage, as it is not trivial.
>>
> The promised PiL3 should have such elucidations, yes.  But the manual? No.
>
> The F in RTFM does not really stand for "friendly".
>
>

I think the manual just imply it, see 3.5 in
manual(http://www.lua.org/manual/5.2/manual.html#3.5):

Lua is a lexically scoped language. The scope of a local variable
begins at the first statement after its declaration and lasts until
the last non-void statement of the innermost block that includes the
declaration.

and 3.3.4:

For syntactical reasons, labels in Lua are considered statements too

so we know:

- local variable's scope ends after the last non-void statement of block.
- the label statement *is* a void statement.
- so the local variable's scope is end *before* the label statement.
- so, you don't jump into the local's scope :-)

So.... maybe the manual is not that "friendly", but just enough :-)