4 ms·
In my opinion, operators overloading could be safely used if they were explicit. With something like that: var x = a [+] b; There is no possible mistake.
by stephc_int13 5y ago
In my opinion, operators overloading could be safely used if they were explicit.
With something like that:
var x = a [+] b;
There is no possible mistake.
- dnautics 5y agoproposed and rejected. I went to a lang meeting and tried to steelman the issue, without having a strong investment either way (I had one use case, where I would slightly prefer the infix operation). https://github.com/ziglang/zig/issues/8204 https://github.com/ziglang/zig/issues/8204
- stephc_int13 5y agoGood to see it was discussed :) It is probably better to have native support for small vector operations, as this can also help to streamline SIMD optimization. In practice (as a video game dev) I only use operators overloading to have infix notation on vector maths.
- skohan 5y agoYeah gamedev/simulation is the use-case where I think operator overloading is really a value-add. It's really nice to be able to write linear algebra code which reads like math.