[Development] Units in QML

Welbourne Edward edward.welbourne at theqtcompany.com
Thu Feb 18 15:37:13 CET 2016


> Of course I am going slightly off-topic with this thoughts...
So let's have a change of Subject.

> The QML based DSL driving it would benefit greatly if one could easily
> express the physical unit of each number (ampere, newton, meters, ...)
> and if one could preserve this information during calculations.

I've played with this problem [0] extensively.  It turns out to be quite
tricky to do at all well, in general.  There are some amusing petty
problems (like dealing with the milli kg - a base unit has a quantifier
in its name, which makes quantifiers trickier to get right).  There are
units that conflate - a torque should be measured in Nm and not
expressed in J even though J = Nm is normally valid (in one case, the
force and displacement are perpendicular, in the other parallel).  It's
fairly easy to do a clumsy job - [0] just reduces everything to base
units and leaves the user to divide by a composite unit they'd sooner
have seen used - but hard to do a systematically good job.  My design
notes for how to do better are the worst case of second system effect
I've ever embarked on.  Here be dragons.

[0] https://github.com/ediosyncratic/study.py/tree/master/value

	Eddy.



More information about the Development mailing list