News for hackers. Stuff that matters.
Re:The type system is a programmer's best friend by hgomersall on Saturday November 05, 2022 @12:47PM (#33483152)
It's possible to go even further than just protecting against the wrong unit in the wrong place. You can generalise units: https://docs.rs/dimensioned/latest/dimensioned/

(Edit, that's not possible in c++)

Re:The type system is a programmer's best friend by jdrek1 on Saturday November 05, 2022 @01:38PM (#33483660)
> (Edit, that's not possible in c++)

Mind expanding on that? Because what that readme there shows is absolutely possible in C++, I have used a similar system for dealing with natural units.

Re:The type system is a programmer's best friend by hgomersall on Saturday November 05, 2022 @02:00PM (#33483926)
I'm happy to admit I'm wrong on that. My understanding is the bit that makes (kg.m)/s^2 type equivalent to a N, equivalent to J/m is not implementable in the same generic way.
Re:The type system is a programmer's best friend by pencilguin on Saturday November 05, 2022 @04:42PM (#33485460)
All unit systems decompose each unit to primitives, that can then be aliased for notational convenience. So, a result of J/m decomposes the same as a N.