Many other languages have a continue statement that skips the rest of the current iteration of the innermost loop. In Lua 5.2, this can be imitated using goto:
> for i = 1, 10 do
>> if i>3 and i<6 then goto continue end
>> print(i)
>> ::continue:: -- a name surrounded in :: :: is a goto label
>> end
Is this possible in Lua 5.1.4.
(LOVE 8.0 Uses Lua 5.1.4 right? or 5.2)
I don't think LÖVE would support goto statements unless compiled to use LuaJIT, which does backport the feature from Lua 5.2. However, I am only speculating.
Edit: And yes, LÖVE uses Lua 5.1 by default, not 5.2.
The goto statement was only introduced in Lua 5.2.
Since Löve uses Lua 5.1.4, you won't have it.
Actually I don't feel like using it, but I reckon goto might have some advantages.
Anyway, as Xugro mentionned, there's the break statement, and that's fairly enough.
In the above post, goto is used to simulate a "continue" not a "break". "Break" ends the loop and jumps to the part after the loop. "Continue" only ends the current iteration of the loop and goes to the next iteration. I haven't used it ever, though.
I thought it would be useful for situations where you would need to jump to a specific function outside your loop instead of just the next one outside your loop.
But I actually don't have use for it in my code. just interested to know if it was possible in 5.1.
Whats wrong with 5.2? I thought since it being a later version its better. maybe not since LOVE sticks to 5.1
This is somewhat off topic, but what are the obvious, large issues with Lua 5.2 that stand in the way of LÖVE using it? The first thread mentions some backwards compatibility problems, which is what I am the most interested in. Since 5.2 will be two years old next month I don't feel like the "it's too new" argument has much merit anymore.
ejmr wrote:This is somewhat off topic, but what are the obvious, large issues with Lua 5.2 that stand in the way of LÖVE using it? The first thread mentions some backwards compatibility problems, which is what I am the most interested in. Since 5.2 will be two years old next month I don't feel like the "it's too new" argument has much merit anymore.
If Lua 5.2 is not built in compatibility mode, a lot of code written for Lua 5.1 will not work in 5.2. The same goes for Lua libraries - the current Luasocket release only works in Lua 5.1 or Lua 5.2-with-compatibility with some slight modifications to Luasocket.
Code written for Lua 5.1 is completely compatible with LuaJIT without any modification. The same is not true for code written for Lua 5.2.
LÖVE 0.9.0 will use LuaJIT by default. If the choice is either Lua 5.2 or LuaJIT for games, I'd pick LuaJIT 100% of the time.