• Subject: Re: Lua 5.2 and continue
• From: Aleksey Yutkin <ayutkin@...>
• Date: Tue, 2 Feb 2010 16:53:16 +0300

EXAMPLE:

for i = 1, ni do
...
if condi1 then continue end
...
if condi2 then continue end
...
if condi3 then continue end
...
if condi4 then continue end
...
if condi5 then continue end
...
if condi6 then continue end
...
if condi7 then continue end
...
if condi8 then continue end
...
for j = 1, nj do
...
if condj1 then continue end
...
if condj2 then continue end
...
if condj3 then continue end
...
if condj4 then continue end
...
if condj5 then continue end
...
for j = 1, nj do
...
if condk1 then continue end
...
if condk2 then continue end
...
if condk3 then continue end
...
if condk4 then continue end
...
if condk5 then continue end
...
if condk6 then continue end
...
if condk7 then continue end
...
if condk8 then continue end
...
if condk9 then continue end
...
if condk10 then continue end
...
end
...
if condj6 then continue end
...
if condj7 then continue end
...
if condj8 then continue end
...
if condj9 then continue end
...
if condj10 then continue end
...
end
if condi9 then continue end
...
if condi10 then continue end
...
if condi11 then continue end
...
if condi12 then continue end
...
if condi13 then continue end
...
if condi14 then continue end
...
if condi15 then continue end
...
if condi16 then continue end
....

end

2010/2/2 Leo Razoumov
On 2010-02-02, Mark Hamburg <mark@grubmah.com> wrote:
> It's worth remembering that you can program with continue, but it costs you the > ability to break out of the loop:
>
>         real loop do
>                 repeat -- make continue work
>
>                         if some_condition() then
>                                 break -- continue
>                         end
>
>                 until true
>         end
>

This is precisely the problem. You are emulating 'continue' at the
cost of loosing 'break' operation. The goal is to have them both doing
their respective things within the same loop.

Regarding 'repeat...until'. I am not using it at all. Mentally, I am
always tempted to write 'repeat...until false' where I am supposed to
write 'repeat...until true'. Having been bitten by this issue several
times I ceased to use 'repeat...until' altogether replacing it with
'while true do ... if something then break'.

--Leo--