3 ms·
IMHO better than operator overloading (which opens the gates to hell) would be builtin vector and matrix types like in shading languages. Currently Zig has a ve
by flohofwoe 5y ago
IMHO better than operator overloading (which opens the gates to hell) would be builtin vector and matrix types like in shading languages. Currently Zig has a vector type builtin (search for @Vector and/or std.meta.Vector), which supports the "simple" operations (addition, subtraction etc...), so it's halfway there, but no swizzle, and no matrix types.
- Hoppetosse 5y agoThe @Vector provided is actually a reference to SIMD vectors and there has been discussion to rename it to something that reflects this more clearly. https://github.com/ziglang/zig/issues/7305 https://github.com/ziglang/zig/issues/7305
- flohofwoe 5y agoI would love to see Clang's ext_vector_type extension features in Zig, it lets you write code like GLSL, including easy swizzling. Add the same thing for matrix types, and the the feature would be complete, no need for operator overloading: https://www.godbolt.org/z/zWGfcY5a4 https://www.godbolt.org/z/zWGfcY5a4 Whether this code translates to SIMD or scalar operations under the hood should depend on the target platform and compiler options.