Late to the thread, but fyi, there’s something sneaky being done here to keep Unitful types from being exceedingly long when printed, which is something people have disliked in the past. The cm^-3
inside the type signature is actually this:
julia> Unitful.Unit{:Meter, u"𝐋"}(-2,-3)
cm⁻³
The Unitful.Unit
type is never manipulated by the user and is for internal use only. Having Unitful types show in a succinct way that still yields enough information to construct the type at the REPL has proven challenging. I think a step in the right direction would be to at least distinguish the two cm
objects by having the internal one display differently, to avoid pulling a fast one on everyone. Sorry for that.
If you find yourself wanting to manipulate Unitful types directly, there’s almost always a better way. I would follow Tim’s advice here. You could consider restricting to cm^-3
in the constructor if desired, though I’m not sure why you would need to do that.