3 ms·
On point 4, I don't use zig but a two second google leads to http://ratfactor.com/zig/stdlib-browseable2/math/atan.zig.html http://ratfactor.com/zig/stdlib-brow
by amoss 1y ago
On point 4, I don't use zig but a two second google leads to http://ratfactor.com/zig/stdlib-browseable2/math/atan.zig.html http://ratfactor.com/zig/stdlib-browseable2/math/atan.zig.ht...
I wonder about the accuracy of the rest of the article.
- bsder 1y agoThe issue is that atan wasn't implemented for a comptime float. A "comptime f32" is different from an "f32"
- jamiejquinn 1y agoIf you don't use zig, you might have missed why that error indicates a stdlib bug. The error in the article is down to a quirk of the type system where literals (like the literal float) have their own unique type (comptime_float) that can coerce to related types (f32, f64) but in this particular case, when atan switches on the type, it doesn't explicitly include comptime_float and fails. Seems like an oversight in the stdlib to me.
- amoss 1y agoMissed 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.