Re:Zig Structs of Arrays (2024)
by dnautics on Monday June 08, 2026 @06:06PM
(#48452957)
no, in general overloading is not syntactic sugar, it's a feature of the language (being able to (re-)define a function in place X and have it change the function in unrelated place Y).
[ Parent
| on HN ]
Re:Zig Structs of Arrays (2024)
by fluffybucktsnek on Monday June 08, 2026 @06:50PM
(#48453493)
I don't see how it is unrelated. If have a custom type `A` with an overload on `+`, it will only affect places I used custom type `A`. If there wasn't operator overloading, I would just have to use a different notation to call the same function, but with possibly worse ergonomics (which is also why I think your solution doesn't really satisfy that, it doesn't read like algebra which is kind of the point). Given that type A is presumed to be custom, I don't see how place Y would be unrelated since it deliberately uses type `A`.
If we include operator overloading for any types, then sure. i32 + i32 might suddenly start meaning something else. But I think that's beyond the scope of what is normally asked by operator overloading.