lua-users home
lua-l archive

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


On Tue, Sep 20, 2005 at 09:38:39PM -0500, jrs@tbrve.net wrote:
> 
> A little late, but ...
> 
> The semantics of continue is available in Lua. No patch required.
> 
> while something do
>   repeat
>     ...
>     if expr then break end
>     ...
>   until true
> end
> 
> Here 'break' is read as 'goto end of block' ('continue', if you
> prefer :-)), and 'repeat ... until true' is read as 'block ... end'.
...

too sad you are losing the semantics of break -- bad deal.

likewise with
i=0
while (function () -- clearly you'd rather create function only once
  print(i) -- but it would be less readable
  if i<3 then return true end -- continue
  -- break
end)() do
  i=i+1
end

now you have break and continue plus a "continue block",
but sacrificy return.


salut