|
|
|
|
|
by dbandstra
1999 days ago
|
|
I wouldn't call that careless. So far, proposals to extend the for-loop have not passed the cost/benefit test. I think supporting iterators would require something like magic-methods, which so far are not a thing in Zig (language syntax doesn't interact with userland code). The status quo for iterators is this: var it = getSomeIterable();
while (it.next()) |item| {
...
}
IMO it's "good but not great" (not great because it adds a var and the variable pollutes the outer scope). But the alternative is a bit of a pandora's box. |
|
I understand where it's coming from, but having something like "for (i32 i in [0,n[)" would be so much nicer in my opinion.