It uses operator overloading of [] &[] and "len" to create a straight for loop. Normal C for loops are there of course.
back
1 comments
I just skimmed the C3 spec[1] on foreach and foreach_r, and I'm still confused as to how to move elements by anything other than 1, if it's even possible.
[1] https://c3-lang.org/implementation-details/specification/#fo...
It isn't possible. Use `for` instead. `foreach` isn't trying to be a one-stop-shop, but rather help the common case of looping over an array or list. Because it handles caching the length and such it's more efficient than a casually written `for` loop. This is the 90% solution to iteration.
Ah that makes sense, as long as the length doesn't change during iteration, which like you said is the 90% case. As long as I also can use for(), then that's fine.
Yeah, you will need to pry `for` from my dead cold hands.