Re:Zig: The Modern Alternative to C
by tialaramex on Friday March 10, 2023 @03:44PM
(#35100750)
The good news is that although intuitively that feels horrible, mechanically those are string literals, so, that doesn't actually do very much, just re-assigning a pointer. Moreover, there's no way an optimising compiler can't see those assignments are futile and elide them, whereupon in release builds it might as well be a comment.
And yes, lots of people who don't like Zig's choice agree unused variables are bad and shouldn't survive into your release code. They just don't agree with Andrew that it's a fatal error and the program shouldn't build.
For me, I often unused variables in production code are usually filling the void a comment or good design would have filled.