3 ms·
So i cannot have algebraic types like vec3 etc in zig? It says there are no operators. In my view modern languages should provide vector math stuff.
by jokoon 6y ago
So i cannot have algebraic types like vec3 etc in zig? It says there are no operators.
In my view modern languages should provide vector math stuff.
- hansvm 6y agoIt's a design trade-off. Zig makes understanding the code with only local context a fairly high priority (also see their multiline string syntax), and that's more-or-less incompatible with user-defined operators.
- kristoff_it 6y agoYou can have vectors, you just have to either comptime or runtime dispatch over methods, rather than through overloading operators. I understand for some people that's not going to be satisfactory enough, but it's not something that can't be done in an absolute sense.
- fulafel 6y agoAlgebraic data types are synonymous with composite types like eg structs, which Zig has... though the structs are anonymous.
- woggy 6y agoOne of the goals of Zig is to keep the language simple. From the website: "There is no hidden control flow, no hidden memory allocations, no preprocessor, and no macros. If Zig code doesn't look like it's jumping away to call a function, then it isn't. This means you can be sure that the following code calls only foo() and then bar(), and this is guaranteed without needing to know the types of anything:"