4 ms·
Some of the comments in the page mention Zig. While Zig has iterators for slices, the simple "for" loop (that actually uses the while keyword) makes you define
by biryani_chicken 5y ago
Some of the comments in the page mention Zig. While Zig has iterators for slices, the simple "for" loop (that actually uses the while keyword) makes you define the variable outside the loop:
var i: usize = 0;
while (i < 10): (i += 1) {
//use i
}
I hope they fix this before 1.0.
- mariusor 5y agoI watched Jonathan Blow's introduction to macros in the Jai language[1] that he develops. Basically he made the for loop to be a macro (what he called a "hygienic macro") and it can be overloaded for various types of iterators. (watch past minute 6:30) [1] https://www.youtube.com/watch?v=QX46eLqq1ps https://www.youtube.com/watch?v=QX46eLqq1ps
- nyanpasu64 5y agoI don't use Zig but follow its development a bit. Zig has or may add foreach-like loops over one or more collections: https://github.com/ziglang/zig/issues/7257#issuecomment-1030588319 https://github.com/ziglang/zig/issues/7257#issuecomment-1030...