lua-users home
lua-l archive

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

* Roberto Ierusalimschy:

>> * Roberto Ierusalimschy:
>> > Any comment about this?
>> >
>> >
>> "until" could have been "break if", and the "repeat ... until exp"
>> could have been "repeat ... break if exp end", where "repeat ... end"
>> is an endless loop.
> It is, and that is the problem. If you have repeat + continue, it
> becomes this:
>   repeat ... continue ... break if exp; end
> With this interpretation, the continue goes to the end of the loop,
> bypassing the "break if exp". This is not what most people expect
> from continue.

Heh, nice catch.  Perhaps "continue" is simply not that useful with
loops where the exit condition is checked at the end.

Unfortunately, I avoid such loops in my coding (independently of the
language), so I haven't got example to check if it would be useful in
some cases at least.  (I use "continue" regularly in for and while
loops in other languages, FWIW.)

> BTW, this is completely parallel with while, which may read
> as "repeat break if not exp; ... end". But this intepretation has
> no problems with continue.

Oh, I still remember that when I first tried to implement "continue"
with a goto, I put the label at the beginning of the loop body, and
was surprised when it didn't work as expected.