3 ms·
Missed all of that, thanks for the explanation. Why doesn't zig try and apply the coercion before the type switch - is this deliberate for safety?
by amoss 1y ago
Missed all of that, thanks for the explanation. Why doesn't zig try and apply the coercion before the type switch - is this deliberate for safety?
- pcwalton 1y agoBecause "else" technically includes "comptime_float", so that case is handled, just not in the way that's expected. One of the downsides of comptime over generics is that, because it's low-level and procedural instead of high-level and declarative, things like automatically inserting coercions become harder.
- jamiejquinn 1y agoI'm not sure but I would guess it's in the spirit of Zig's "explicit over implicit" philosophy. They are technically different types.