[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Next Version of Lua?
- From: Florian Weimer <fw@...>
- Date: Thu, 11 Jun 2009 17:02:32 +0200
* Roberto Ierusalimschy:
>> * Roberto Ierusalimschy:
>> > Any comment about this?
>> > http://lua-users.org/lists/lua-l/2005-09/msg00548.html
>> "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.