[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc2) now available
- From: David Kastrup <dak@...>
- Date: Wed, 22 Jun 2011 17:23:07 +0200
Lorenzo Donati <email@example.com> writes:
> On 22/06/2011 8.50, David Kastrup wrote:
>> Lorenzo Donati<firstname.lastname@example.org> writes:
>>> I was just thinking of it right now. I'm not a fan of continue, but I
>>> find it really useful sometimes.
>>> Now that the goto machinery is in place, wouldn't a "continue" keyword
>>> be useful and easily introduced? If I remember well, Lua authors
>>> weren't contrary to it in principle, but because of the
>>> incompatibilities with "until".
>>> Now this seems to work:
>>> ::continue:: -- hidden label if continue were introduced
>>> until word == nil
>> I mentioned this before: the purpose of "continue" is a short-circuit of
>> a loop before its regular completion. A while-loop _starts_ with the
>> check of the loop condition as a prerequisite to its regular execution.
>> A repeat-loop _finishes_ with the check of the loop condition as a
>> _consequence_ of its regular execution.
>> For that reason, you want "continue"-like behavior to resume a
>> repeat-until loop _at_ _the_ _top_ of the loop body, not at the point
>> where the condition is checked, since the condition is a _product_ and
>> not a prerequisite of the regular execution, and continue short-circuits
>> the regular execution.
>> If you claim possibility for confusion: show me real existing code
>> (rather than theoretic speculation) using "continue" inside of "do
>> .. while".
> The last sentence confused me. Did you mean "inside of repeat..until"
> or "inside while..do..end" ? "do .. while" doesn't exist in Lua. Or
> are you hinting at another language usage?
It would be rather hard to show real existing code using "continue" in
Lua, wouldn't it?
> As I said, I think I read in an old message by Roberto or Luiz (in an
> old of those endless threads about the beauty of continue) that Lua
> team wasn't in principle contrary to the introduction of continue as a
> counterpart of break, but the problem was that it was too tricky to
> get it right with the current (5.1.4) semantics of repeat-until
> because of the possibility of bypassing the scope of a local declared
> after the continue (*IIRC* - please feel free to correct me if I'm
That's because they decided to think about continue in the C way, which
is a rather useless way.