2 ms·
Surprised that I'm the only person so far mentioning F#, where units of measure have been built in to the language since 1.0: https://learn.microsoft.com/en-us/
by nicklecompte 3y ago
Surprised that I'm the only person so far mentioning F#, where units of measure have been built in to the language since 1.0: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/units-of-measure https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
I wrote a longer comment in reply to nraynaud elsewhere describing how I found it useful for certain things at a past job. It's hardly a killer feature, but it's very nice to have the compiler (partially) verify the semantic correctness of certain floating-point computations. It's not just physics - finance has "units" as well, and the compiler can complain if you gave a function an array of dollars/week when it wanted dollars/month.
If you don't mind writing some (admittedly tedious) overhead it can save a lot of headaches.
- tesdinger 3y agoGiven that months have varying amounts of days, does it even make sense to have both dollars/month and dollars/day in the same setting? I would figure you would use either one or the other.
- nicklecompte 3y ago> does it even make sense to have both dollars/month and dollars/day in the same setting? Parking downtown often has daily and monthly rates: is it cheaper to pay for two months, or one month and ten days? If you're doing the math yourself it's immediately obvious if you accidentally swap the rates, but not so if you write a program that swaps the variables. You wouldn't write a program at all for this example, but it's a legitimate use case. Your general point is correct: it typically doesn't make sense to have them in the same setting if by "setting" you mean "specific equation." But they could very well be in the same program.