Open sostock opened 3 years ago
One consequence of the intransitive isequal
is that a correct hash
implementation for Gain
is impossible: We have
isequal(Gain{Decibel, :p}(20), Gain{Decibel,:rp}(20))
,isequal(Gain{Decibel, :p}(20), 100)
, andisequal(Gain{Decibel,:rp}(20), 10)
,but hash(10) != hash(100)
.
Can someone explain why Unitful stores :p
or :rp
?
Why is it we aren't just storing a logarithmic value along with linear units and logarithmic multiplier it was calculated with, and converting to power or root-power when requested?
When comparing a power gain
Gain{L, :p}
and a root-power gainGain{L, :rp}
with the sameL
, they get promoted toGain{L, :?}
without changing their numerical values. This breaks the transitivity of==
:Comparison involving numbers is intransitive as well:
To obtain a consistent behavior for
==
, the promotion rules forGain
would have to be changed. It might be difficult to figure out a set of rules that is both practical and consistent, unless one gets rid ofGain{L, :?}
altogether.