3 ms·
A lot of people are getting hung up on the "math never decreed" sentence (not entirely wrongly since it's basically false, and surprising for Casey who has prob
by morelisp 4y ago
A lot of people are getting hung up on the "math never decreed" sentence (not entirely wrongly since it's basically false, and surprising for Casey who has probably forgotten more linalg than I'll ever know), but that's not really the point of the article.
The point is that notationally, turns seem to read better in most code that isn't doing analysis. I'd say this points more to a flaw in our languages than in our function definitions. Of the major general-purpose languages I think only C++ has really taken a shot at implicit unit conversion, which would let you safely and correctly sum a `turn facing` and `degrees delta` and pass the result to a `float sin(radian x)` function and statically ensuring your dimensions remain correct.
Everything else I can think of either makes newtypes too complicated to define, lacks conversion overloads (or more likely lacks operator overloads entirely), or refuses to let you do them implicitly. C++'s approach is certainly too general, but is it really impossible to corral such behavior in a way that's both safe and convenient?