Rule 1: Don't write any code that can make the ship go ka-boom.
Rule 2: We need to consistently use the f'ing metric system and SI units - and don't you forget it.
Rule 3: ... You haven't already forgotten about rule #2, have you?
Rule 1: Don't write any code that can make the ship go ka-boom.
Rule 2: We need to consistently use the f'ing metric system and SI units - and don't you forget it.
Rule 3: ... You haven't already forgotten about rule #2, have you?
typedef struct { float value; } meter;
typedef struct { float value; } feet;
Using strong typing, you can avoid passing values in wrong units.
https://github.com/mpusz/mp-units
which does all sorts of checking, allows arithmetic with proper accounting for units and so on. But yes, the basic notion is wrapping things in structs which can't be simply assigned to each other.
Maybe the answer is that strong typing should somehow continue outside of the individual programs and be embedded in file formats as well?