Posted: Mar 25, 2012 10:59 pm
by mizvekov
VazScep wrote:...
The only weaknesses of units of measure I've encountered arise due to type-erasure, but I can't remember the particular issues off-hand. I remember them being relatively easy to circumvent though. There is also the obvious problem that functions such as "sqrt", as implemented in any programming language, is never going to have the correct unit of measure. So in these cases, you have to cast.

That is very cool :) . Need to bump F# up in my priorities list.
By the way, I think something similar could be implemented in c++ with a new feature called "user defined literals".
Code: Select all
double operator "" _yard(long double val)    { return val*0.9144; } // converts to meters
int main() { std::cout << 12.3_yard << std::endl; }

Now I think that with a good type hierarchy and some overloading of the arithmetic operators, it should be possible to implement something similar, but perhaps not as powerful with regards to type inference.

VazScep wrote:Seriously did not know this. I've been complaining about the difficulties in binding to a C++ dll, and the pain of having to wrap everything up as extern C functions. I had no idea C++ programmers are in the exact same situation!
Yes, unfortunately so :)
That is specially harder on linux and other unix systems, where there are no commonplace equivalents to COM.

By the way, still haven't forgotten about the propositional logic system we were discussing, it's just that I have been busy with more pressing matters :whistle: