Retoor software development Projects Research SearchXNG
Register Sign In

18 lines
225 B
Plaintext
Raw Normal View History

feat: implement for-in loop syntax with iterate/iteratorValue protocol and break support Add `for (variable in sequence)` syntax to the Wren language, introducing the `in` keyword token and compiler support for iterating over sequences using `iterate` and `iteratorValue` methods. Includes new benchmark files for Lua, Python, Ruby, and Wren, plus test cases covering single-expression bodies, block bodies, closures over loop variables, and break statements. Also fixes a missing POP() in CLOSE_UPVALUE and moves the while test file to a subdirectory.
2013-12-25 06:04:11 +01:00
var list = []
{
var i = 0
while (i < 2000000) {
list.add(i)
i = i + 1
}
}
var start = OS.clock
var sum = 0
for (i in list) {
sum = sum + i
}
IO.write(sum)
IO.write("elapsed: " + (OS.clock - start).toString)
Reference in New Issue Copy Permalink
b72a42eedd
wren/benchmark/for.wren
Response time: 29ms
Mail Licenses API