umka-lang icon indicating copy to clipboard operation
umka-lang copied to clipboard

`for..in` with integer bounds

Open vtereshkov opened this issue 5 months ago • 1 comments

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)
}

vtereshkov avatar Jun 29 '25 20:06 vtereshkov

Partially covered by #539.

vtereshkov avatar Nov 04 '25 15:11 vtereshkov