Loops overhaul #214
Replies: 2 comments
-
pinging @lushoBarlett |
Beta Was this translation helpful? Give feedback.
-
I don't disagree on the idea of iterables and being able to use for loops on them. I'll have to think about your other proposal. ThoughtsThe language is focused on consistency. Having two kinds of for loops would not do the trick, I'd say. Having the declaration be local to a loop is something that we really want. You know how much I despise working on Python, one of the things I can't stand are the while loops, and there is no choice, unlike other languages where "traditional" for loops are available. So the way we choose to do while loops if there is no other option is very important to me. I can't decide wether it is better to allow or to ban the third statement in the while loop, I'm of the idea that it's useful to have it. I personally tend to forget about the increment otherwise. I guess you get used to it, since for the language it would be the only way to do it, but I see it as kind of ugly. Then again, with the new for loops, while loops where you use an index would be rare, but there's the classic iterating over two things at the same time. Which is pretty common still. Perhaps we can enhance the capabilities of iteration later to include more of these cases. For example: for (x, &y in arr1, arr2)
y = x; where & signals a reference. ConclusionSure, it's not my favorite but I can go both ways really. |
Beta Was this translation helpful? Give feedback.
-
I want to change how loops work in the language. I believe for-loops should be over collections, not slightly-different while-loops. At the same time, being able to (optionally) declare a variable in the header of a loop is really nice, so I want to add that functionality to while-loops.
I haven't decided on the new syntax of for-loops, but here is a mock-up:
Beta Was this translation helpful? Give feedback.
All reactions