You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The nature of this package makes ambiguities easy to create – it wants to overload "all" arithmetic operations basically. Some examples below.
Of course, one could directly follow the recommendation from error messages and define those specific methods. But it seems like an endless game of whacking more and more ambiguities.
I wonder if you had some thoughts on more principled approaches to avoid them? If that's possible at all...
julia> (1±2)^(2//1)
ERROR: MethodError:^(::Particles{Float64, 2000}, ::Rational{Int64}) is ambiguous.
Candidates:^(p::Particles{T, N}, a::Real...) where {T, N}
@ MonteCarloMeasurements ~/.julia/dev/MonteCarloMeasurements/src/register_primitive.jl:44^(x::Number, y::Rational)
@ Base rational.jl:537
Possible fix, define
^(::Particles{T, N}, ::Rational) where {T, N}
julia>div((5±1), (3±1), RoundNearest)
ERROR: MethodError:div(::Particles{Float64, 2000}, ::Particles{Float64, 2000}, ::RoundingMode{:Nearest}) is ambiguous.
Candidates:div(p1::Particles{T, N}, p2::Particles{T, N}, args...) where {T, N}
@ MonteCarloMeasurements ~/.julia/dev/MonteCarloMeasurements/src/particles.jl:354div(x::Real, y::Real, r::RoundingMode)
@ Base div.jl:341
Possible fix, define
div(::Particles{T, N}, ::Particles{T, N}, ::RoundingMode) where {T, N}
This is an unfortunate consequence of the approach taken in this package together with julia's lack of proper interfaces. It's hard to know what methods to implement to follow an interface, e.g., what does it mean to be a Real?
But it seems like an endless game of whacking more and more ambiguities.
It is if you want to cover everything, but it is not an endless game trying to get one particular calculation working. Getting several particular calculations working has been more or less how this package has been developed. The interaction between two different kinds of "special real", like particles and either of {Quantity, Dual, BigFloat} are prime examples of where lots of extra methods are required. Still, I think it's quite amazing how far you get by this kind of dispatch-based implementation, most workflows do not encounter anything other than Float64, and ones that do are likely sufficiently advanced for it to be acceptable to define a new method here and there
The nature of this package makes ambiguities easy to create – it wants to overload "all" arithmetic operations basically. Some examples below.
Of course, one could directly follow the recommendation from error messages and define those specific methods. But it seems like an endless game of whacking more and more ambiguities.
I wonder if you had some thoughts on more principled approaches to avoid them? If that's possible at all...
The text was updated successfully, but these errors were encountered: