I had this idea for my programming language I am making but it would be cool to have it wherever I can have it.
Basically, need a struct that can wrap numbers and gives the number a unit. Then write conversions between units and operators that check to make sure the units make sense and convert the values if the values' units are convertible between each other.
Can either do this with an enum that has all the units or do some inheritance magic to get it to work
Maybe we could have compound units?? Like how newtons are kg*m/(s^2)
This would only be possible with multiplication and division
I had this idea for my programming language I am making but it would be cool to have it wherever I can have it.
Basically, need a struct that can wrap numbers and gives the number a unit. Then write conversions between units and operators that check to make sure the units make sense and convert the values if the values' units are convertible between each other.
Can either do this with an enum that has all the units or do some inheritance magic to get it to work
Maybe we could have compound units?? Like how newtons are kg*m/(s^2) This would only be possible with multiplication and division