lua-users home
lua-l archive

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


----- Original Message -----
From: Luiz Henrique de Figueiredo
Date: 6/10/2009 4:24 AM
* Lexer Only: A continue statement is in dire need
We don't see such a dire need for that. Plus it does have semantics problems,
due to upvalues in closures, discussed here in the past.
Every person I train in Lua asks me why 'continue' doesn't work. I show them the "equivalent", and it never meets with any kind of satisfaction.

for index = 1, 10 do repeat
   if index == 5 then break end
   -- do stuff
until true end

The standard alternative introduces nested code:

for index = 1, 10 do
   if index ~= 5 then
       -- do stuff
   end
end

I'm in the camp where I see a real need for it in Lua, not only for clarity, but because it is a very useful loop construct that anyone coming from another popular (scripting) language will expect to be able to use.

Josh