-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert
for Periods is a pun?
#16109
Comments
Hmm.....I'm not sure I see the actual problem; I think we're safely within the general meaning of |
The problem is that Here is some food for thought. If I had a type immutable Radian
val::Float64
end
convert(::Type{Radian}, x::Float64) = ??? then what should But the Because these two different approaches lead to a different result, it would seem that they are actually two distinct operations, and Mathematica uses |
related: #15394 |
Duplicate of #10451 |
I agree with @TotalVerb that we need to introduce a mechanism for conversions between incommensurable units that does not rely on One way might be to have a
eg you specify a unit to be divided out from the quantity. |
So basically to be consistent |
Closing as duplicate |
Currently,
convert
is used to extract the magnitude of a quantity, or alternatively to give units to a dimensionless quantity. This happens in theDates
code inBase
, and the behaviour has inspired similar behaviour in SIUnits.jl and Unitful.jl.In Base,
convert
is generally used to convert between values of different types, but with same meaning. Since 1 and 1 second do not represent the same quantity, the use ofconvert
to switch between them is a pun. In addition, it can lead to surprising behaviour. Note:So we have converted an Int back to itself, but the conversion was lossy!
The text was updated successfully, but these errors were encountered: