lua-users home
lua-l archive

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


Mark Hamburg <mark@grubmah.com> writes:

> Three seemingly simple answers to the repeat/until v continue problem
> (in order of decreasing harshness but more complex definitions):
>
> * Disallow continue in repeat/until loops
> * Disallow continue in repeat/until loops where the loop condition
> references a variable declared inside the loop
> * Disallow continue if it makes the loop condition reference variables
> that might not have been declared

There is also another simple solution:
* don't treat continue as part of repeat/until loops

That is, it would continue an outer loop, if any.  More so than
restart-at-top, the result would tend to be unexpected.

In C, sometimes some constructs can be made nicer by making use of the
fact that inside a switch statement, "break" is local to the switch
statement, while "continue" refers to an enclosing loop.

The resulting semantics are useful, but clever.

Lua does not tend to favor cleverness.

> I would say I don't really care about this issue all that much, but I
> do use the break as continue trick a bit more often than feels
> legitimate for someone who doesn't care.

Yup.  Too clever.

-- 
David Kastrup