Mole is dimensionless, isn't it? like Nₐ
The SI system currently uses 7 fundamental units, but it's a standard that is evolving and there is talk of expanding to include other things in the next update. (My system preemptively includes angles and solid angles, which gives it some convenient abilities, for a total of 9.)
Electric current (amp), at least in SI, is considered a fundamental unit. Moles are indeed dimensionless measures of "amount", unrelated to mass. (Dimensionless units themselves are a very complicated subject.)
There are many other systems, of course, and one's degree of instrumentalism may give one other reasons to consider them composite dimensions. As well, this is a continual area of research.
So, to recap: to maintain compatibility with Obj-C, the unit system in the current Foundation uses abstract classes and reference semantics instead of the idiomatic (and more performant) approach of protocols and value semantics. And Measurement
s store their unit, making them a positive-cost abstraction (which, as @taylorswift pointed out, dimensional measurements ideally shouldn’t be).
But before discussing possible alternative implementations of Foundation units/measurements that solve these issues, to what extent can we change the current approach?
Namely, Swift and its standard library (including Foundation) are declared binary-stable on Apple platforms. My understanding is that the Swift rewrite of Foundation is to be the definitive Foundation implementation on all platforms, including Apple’s. So, when deciding how to implement Foundation features (such as the unit system) in Swift Foundation, is binary compatibility with the current Foundation a concern? If so, this may unfortunately limit (partially or completely) how much we can redesign Foundation’s unit system.
Right. Foundation's public definition of Measurement
will not change (at least on existing Apple platforms), due to ABI stability requirements, and the interface on non-Apple platforms can't change (much) as a side-effect, due to source stability requirements.