Continue in loops

I think lua doesn’t offer a continue statement, but would that be easy to add to Codea?

if your in a function you can “return”?

Sometimes, not always. I dont really get the motivation behind not having continue. Main advantage for me is that makes code easier to read.

I was just reading the other day that Lua 5.2 came out and has support for goto statements (I know it’s heresy just to mention goto’s) among other things. You could more or less simulate continue with goto if Codea moves to 5.2.

Not sure if TwoLivesLeft has any plans to put Lua 5.2 on the roadmap for Codea though.

I like goto statements. Without looking at it yet, I think we’d like to upgrade to Lua 5.2 as soon as possible.

goto is evil.

But upgrading to 5.2 won’t force me to use it. :slight_smile: and y’all can learn by getting burnt.

It should be fully backward compatible, and I see “new library for bitwise operations” in the changelog, SWEET!

+1 for ‘continue’ inside a loop.

‘goto’ is evil. But conditional ‘goto’ is not. ‘break’ and ‘continue’ are the examples of conditional ‘goto’.

In the beginning there was BALR R1, R2

AHHG! You guys like goto loops! It doesn’t effect me, but it drives me crazy when people use goto. I prefer functions. I used goto when I first learned to program. I froze my computer (an eMac). Literally froze my entire computer. Back then, I didn’t know why insanity meant. I kept trying to run the program and restart my computer. Eventually, I decided to look at the code. Good ol’ days… :slight_smile:

Goto is easily misused, but it presents some elegant solutions to problems that have to be solved with temporary state variables. Particularly loops with multiple exit points.

Other than basic a long time ago, i’ve never really used goto. What popular modern languages offer it?

Generally speaking, do you stay in the same scope when going-to?

What popular programming languages have goto? C, C++,Go, Fortran, Ada… and that’s just off the top my head :slight_smile:

Stay in the same scope? No, there’s no need for goto in that case. Stay in the same function? Usually, but with nearly any interpreter it’s important to be able to get back to the REPL to recover from an error at any stack depth. In C you do it with setjmp/longjmp, in Lua with xpcall.

heh - you skipped “modern”. Fortran is lovely - but modern it ain’t. Ada is… shudder… I’ve used Ada. With Ada it’s more “what isn’t there?”.

The need to use goto is almost always an indicator you should rethink how you’re doing your code. The places where it’s an elegant solution to things are very, very rare - 99% of goto usage in a modern language that still offers it is misuse rather than use.

Agreed - except that misuse of goto by the many is a poor reason to forbid it for the 1% of cases where it does make your code more readable. :wink:

Maybe an in-app purchase for the “right” to use it? Or misuse it? :smiley:

I agree - with reluctance.

Goto should be in there because they put it in 5.2, end of story. But - it wasn’t in 5.1 and earlier, and we were fine.

I don’t like it not because it could be misused - but rather because I view Codea’s place in the world (other than making money for twolivesleft) as an educational/hacking/play tool. I have the job I have today because I got an 8 bit computer and I spent a ton of time learning it, and until Codea came along, that opportunity was gone; I can see a kid spending time with Codea and learning to code and years from now pointing back at it, in the same way I point back at my Atari 400, and saying “That’s the thing that put me on this career”. And it would just be nice if they learned to do it without goto.

Because I had goto. I learned BASIC. And it was fun, and good, and I had to re-learn later how to do it “right”. And I would spare the next generation that - bad habits die hard.

I think it’s really interesting that there’s someone out there making these decisions about what to include in the language and they’ve just now in v5.2 decided that goto should be included afterall

Good point.

Agree with @bortels. Personally I haven’t found any cases that exclusively need goto as the only solution. But ‘continue’ is still a good language construct. If it’s possible, 2LL should provide ‘continue’ and forbid ‘goto’ in the next Codea update (though it would use Lua 5.2).

@ruilov: Yes, I wonder about that too. :slight_smile:

Disagree there - stock Lua, most recent stable version, is the way to go. Compatability with regular Lua code is very important - I would hate to run into libraries we can’t use because goto was eliminated for ideological reasons.