The unit and dimension functions return NoUnits/NoDims for quantity types without well-defined units/dimensions:
julia> unit(Quantity{Int}) # return `NoUnits`, which is not printed
julia> dimension(Quantity{Int})
NoDims
I consider this a bug, since NoUnits/NoDims represent an actual unit and an actual dimension. Using the same value NoDims for dimensionless objects (like 5u"m/mm", which has a well-defined dimension) and for objects without well-defined dimension (like Quantity{Int}) seems wrong to me.
Instead of a bug, this could also be seen as a pun on the NoUnits/NoDims values: They do not only represent dimensionless objects, but also objects without well-defined dimension. Still, using the same values for both of these concepts seems wrong to me. And I’m not convinced the pun is intentional. After all, calling unit/dimension on other values without well-defined dimensions does error:
julia> unit("foo")
ERROR: MethodError: no method matching unit(::String)
[…]
julia> dimension("bar")
ERROR: MethodError: no method matching dimension(::String)
[…]
The
unit
anddimension
functions returnNoUnits
/NoDims
for quantity types without well-defined units/dimensions:I consider this a bug, since
NoUnits
/NoDims
represent an actual unit and an actual dimension. Using the same valueNoDims
for dimensionless objects (like5u"m/mm"
, which has a well-defined dimension) and for objects without well-defined dimension (likeQuantity{Int}
) seems wrong to me.Instead of a bug, this could also be seen as a pun on the
NoUnits
/NoDims
values: They do not only represent dimensionless objects, but also objects without well-defined dimension. Still, using the same values for both of these concepts seems wrong to me. And I’m not convinced the pun is intentional. After all, callingunit
/dimension
on other values without well-defined dimensions does error:Also,
unit(Quantity{Int})
is hitting this method, which makes it seem more like an oversight than an intentional pun: https://github.com/PainterQubits/Unitful.jl/blob/f9992c08c5917f0cb6402bce26cd0a71a61ceb97/src/utils.jl#L133