lua-users home
lua-l archive

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


Lorenzo Donati <lorenzodonatibz@interfree.it> 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".

-- 
David Kastrup