Yes, and if you're paranoid you can write
if (comptime T == u8) {
// code
}
to guarantee that if you're wrong about how the compiler behaves then you'll get a compiler error.Yes, and if you're paranoid you can write
if (comptime T == u8) {
// code
}
to guarantee that if you're wrong about how the compiler behaves then you'll get a compiler error.
Zig has no type info at runtime so this is and always will be guaranteed to be a comptime check.
Hence the paranoia :-D
But I do think adding explicit `comptime` in places like this is reasonable for the sake of conveying intent to other programmers.