The way you have to declare structs (and unions, enums) in ZIG threw me off when I first saw them. Why write:
const MyStruct = struct { a: i8, b: i8 };
instead of just the normal:
struct MyStruct { a: i8, b: i8 };
Later of course I learned how consistent the const keyword in ZIG is, and that this way when a comptime function returns a type it’s clearer and easier to understand (IMO).
But now I wonder, why isn’t it the same with functions?
Why not say:
const foo = fn(a1: u8, a2: u8) void {}
Instead of how we do it?
Also as far as I know there’s no way to have a function that returns a function, thus you can’t have a generic function. (I know you could wrap that inside a generic struct, but that isn’t the question here)
Also, this way they would be more consistent with function pointers as well.
What I’d like to know is why isn’t the function declaration in ZIG not consistent with the language? Or am I just wrong? 😀