4 ms·
I agree. Zig is great in many ways but I am also so frustrated by some of the obviously horrible unergonomic decisions the core team makes. To this day, you are
by markisus 4y ago
I agree. Zig is great in many ways but I am also so frustrated by some of the obviously horrible unergonomic decisions the core team makes. To this day, you are forced to declare loop index outside the loop body, despite many requests from the community.
https://github.com/ziglang/zig/issues/358#issuecomment-491004876 https://github.com/ziglang/zig/issues/358#issuecomment-49100...
- abainbridge 4y agoI don't understand why fixing issue 358 in the Zig compiler isn't trivial. I don't understand the reluctance. I don't understand why: for (var i: usize = a; i < b; i += 1) { foo(); } for (var i: usize = a; i < b; i += 1) { bar(); } Is worse than: var i: usize = a; while (i < b) : (i += 1) { foo(); } while (i < b) : (i += 1) { bar(); } Which is what happens without the for-loop scoping of the variable. (ie when I cut and pasted, I introduced a logic bug where I forgot to initialize i for the second loop).
- abainbridge 4y agoMaybe there is a good reason. I'd just like to know what it is. My guess is that fixing issue 358 with syntactic sugar would mean that the debug info would show scope blocks that don't correspond to {} in the source, and that is annoying.
- abainbridge 4y agoI also see that this is a bike-shed issue [1]. It probably isn't as important as some other language issues that are complicated enough that I don't even know about them. However, people's first impression of the language matter, so fixing the bike shed matters. [1] https://en.wikipedia.org/wiki/Law_of_triviality https://en.wikipedia.org/wiki/Law_of_triviality
- Aransentin 4y agoThere is an accepted (but as of yet unimplemented) proposal to fix just that: https://github.com/ziglang/zig/issues/7257#issuecomment-1030720073 https://github.com/ziglang/zig/issues/7257#issuecomment-1030...
- markisus 4y agoWow I did not know this! This is really great news.