3 ms·
There is an FAQ for the mp-units project on which this proposal is based about why they chose not to use user-defined literals: https://mpusz.github.io/mp-unit
by SloopJon 3y ago
There is an FAQ for the mp-units project on which this proposal is based about why they chose not to use user-defined literals:
https://mpusz.github.io/mp-units/latest/getting_started/faq/ https://mpusz.github.io/mp-units/latest/getting_started/faq/
If I understand correctly, though, the unit expressions that manifold implements aren't limited to literals, is that correct?
- owlstuffing 3y ago>the unit expressions that manifold implements aren't limited to literals, is that correct? Correct. Unit expressions with manifold are more expressive than with mp-units, as I understand it. With mp-units the unit types themselves are expressively inactive. For instance, with mp-units the type for velocity, _q_m_per_s (?), must be defined statically as a literal. But with manifold it may be defined as an expression in terms of the component unit types. As such the unit for Velocity, m/s, is an _expression_ of dimension units LengthUnit and TimeUnit. Velocity sixtyFiveMilesPerHour = 65 mi/hr; And this provides for user defined literals. VelocityUnit mph = mi/hr; . . . Length distance = 80mph * 3.5hr; It's also a convenience that applies to unitless expressions. For example, manifold defines a Rational number type, which defines a unit-based coercer: RationalCoercion r = RationalCoercion.INSTANCE; . . . var oneThird = 1r/3; Which satisfies other uses, such as: var sixMillionDollars = 6M USD;