3 ms·
I remember a long, long time ago, working on a project that handled lots of different types of physical quantities: distance, speed, temperature, pressure, area
by ryandrake 1y ago
I remember a long, long time ago, working on a project that handled lots of different types of physical quantities: distance, speed, temperature, pressure, area, volume, and so on. But they were all just passed around as "float" so you'd every so often run into bugs where a distance was passed where a speed was expected, and it would compile fine but have subtle or obvious runtime defects. Or the API required speed in km/h, but you passed it miles/h, with the same result. I always wanted to harden it up with distinct types so we could catch these problems during development rather than testing, but I was a junior guy and could never articulate it well and justify the engineering effort, and nobody wanted to go through the effort of explicitly converting to/from primitive types to operate on the numbers.
- librasteve 1y agothis was very much my intent with https://raku.land/zef:librasteve/Physics::Measure https://raku.land/zef:librasteve/Physics::Measure
- yawaramin 1y agoSee https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/units-of-measure https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
- esafak 1y agohttps://nim-by-example.github.io/types/distinct/ https://nim-by-example.github.io/types/distinct/ https://kotlinlang.org/docs/inline-classes.html https://kotlinlang.org/docs/inline-classes.html https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3320.htm https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3320.htm https://doc.rust-lang.org/rust-by-example/generics/new_types.html https://doc.rust-lang.org/rust-by-example/generics/new_types...