lua-users home
lua-l archive

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


On Thu, Aug 5, 2021 at 3:26 PM Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:

> It is a source of syntax ambiguity. Compare
>     return;
>     print("unreachable code")
>
> with
>     return
>     print("unreachable code")

Thank you for the explanation.

> Breaks followed that rule to keep open the possibility of labeled
> breaks.  After goto, we gave up the idea of labeled breaks, but now I
> particularly would prefer that all of them (break/return/goto) followed
> this rule.

Without goto, any statements after transfer of control are
unreachable, and it is best for clarity not to have them. So the rule
makes perfect sense in this case.

With goto, well, they are reachable if there is a label statement just
after the transfer of control.

What speaks against relaxing the current restriction on the return
statement, so that it must be the last statement in its block, or it
must be immediately followed by a label statement?

Cheers,
V.