Open jmeaster30 opened 5 months ago
It would be cool to do:
function add3centimeters(@unit(cm) num: f64) -> (@unit(cm) result: f64 = num + 3cm);
let a = 10m;
let total = a.add3centimeters(); # this will throw an error saying "Parameter must have units as 'cm' but got a unit of 'm'."
Which makes me think of a couple things that are needed:
Add an annotation for units that goes on function parameters or variable declarations.
This would let the compiler emit a warning/error for mismatched units
Not sure if this needs to be a language feature or if it can be implemented in the standard library.