Re:The Swift compiler is slow due to how types are inferred
by atiedebee on Thursday June 13, 2024 @03:44AM
(#40667032)
I'm not very in the loop regarding zig at the moment, but coming from C I would think you could just use 0.0 or 0.0f? Is that not the case?
[ Parent
| on HN ]
Re:The Swift compiler is slow due to how types are inferred
by jiripospisil on Friday June 14, 2024 @06:11AM
(#40679342)
Depends on the context but in general Zig wants you to be explicit. Writing 0.0 is fine at comptime or if you're e.g. adding it to an already known float type, but defining a runtime variable (var x = 0.0; ...) will not work because x doesn't have an explicit type (f16, f32, f64, f80, or f128?). In this case, you would need to write "var x: f32 = 0". You could write "var foo = @as(f32, 0)" but that's just a weird way of doing things and probably not what OP meant.