feat: add range operators and iterator protocol for numeric for loops
Implement `..` and `...` infix operators on Num returning Range objects that support the iterator protocol, enabling concise numeric for loops like `for (i in 1..10)`. Add Range class with min/max properties and iterate/iteratorValue methods. Introduce TOKEN_DOTDOT and TOKEN_DOTDOTDOT lexer tokens with PREC_RANGE precedence in the compiler. Unroll method_call benchmark loops across all languages to stress dynamic dispatch instead of loop overhead, reducing iteration count from 1M to 100K with 10x unrolling. Update Wren benchmarks (binary_trees, fib, for) to use new range syntax. Add benchmark/README.md documenting each benchmark's purpose.
This commit is contained in:
+1
-3
@@ -7,9 +7,7 @@ var fib = fn(n) {
|
||||
}
|
||||
|
||||
var start = OS.clock
|
||||
var i = 0
|
||||
while (i < 5) {
|
||||
for (i in 1..5) {
|
||||
IO.write(fib.call(28))
|
||||
i = i + 1
|
||||
}
|
||||
IO.write("elapsed: " + (OS.clock - start).toString)
|
||||
|
||||
Reference in New Issue
Block a user