umka-lang
umka-lang copied to clipboard
`for..in` with integer bounds
The generic for loop is very slow when simply iterating over a range of integers — see benchmarking results in https://github.com/vtereshkov/umka-lang/issues/163.
Automatically analyzing the loop header for patterns like for i := 0; i < n; i++ is hard, both because it requires an infinite lookahead in the parser and because n is allowed to change during the iteration.
We could have a highly optimized for loop version similar to that used in Go since 1.22:
for i in n { // 0 to n - 1
foo(i)
}
or
for i in m..n { // m to n - 1
foo(i)
}
Partially covered by #539.