lua-users home
lua-l archive

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


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--