lua-users home
lua-l archive

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


Arnaud Delobelle <arnodel@gmail.com> writes:

> In the Lua 5.4 docs it says the following.
>
> >   A label should not be declared where a label with the same
> >   name is visible, even if this other label has been declared
> >   in an enclosing block.
>
> I have found the following test in the Lua 5.4.3 Test Suite (available
> here: http://www.lua.org/tests/), in the file goto.lua (starting line
> 223):
>
> [...]
>
> In this function the label ::l1:: is declared twice, once in the
> "elseif a == 4" clause and once at the end of the function.  In my
> understanding, the second declaration of this label is visible at the
> point where the first declaration is made.  That would contravene the
> rule I have quoted above.

I believe the cited paragraph from the docs must be read as a
recommendation rather than a rule: the label *should not* be declared,
but if people do, the behavior is still well-defined (and tested in the
test suite).  RFC 2119 phrases it best:
<https://datatracker.ietf.org/doc/html/rfc2119>

> 4. SHOULD NOT   This phrase, or the phrase "NOT RECOMMENDED" mean that
>    there may exist valid reasons in particular circumstances when the
>    particular behavior is acceptable or even useful, but the full
>    implications should be understood and the case carefully weighed
>    before implementing any behavior described with this label.

Cheers,
Albert

-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124