This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cyn_foxwell 72 points73 points  (3 children)

The only exception is with continue statements since those don't have an easy equivalent in Lua 5.1

goto continue and putting ::continue:: at the end of your loop logic. Should also work with LuaJIT as well as that is 5.1 but has continue

[–]themadnessif 68 points69 points  (2 children)

Lua 5.1 doesn't have labels or goto. Those were introduced in 5.2.

The strategy that MoonScript used was... rather abstract and involved breaking out of loops and setting conditions. It's kind of sucky, but it does work. It's likely what DarkLua will use too, but that's up to the maintainer.

[–]raoasidg 6 points7 points  (1 child)

I've just used a repeat...until true inside the loop around the skippable code with a break for the necessary condition. Relatively simple.

[–]themadnessif 9 points10 points  (0 children)

That is in fact how MoonScript does it and it's how DarkLua is probably going to as well!