The problem doesn’t seem the comparison of Decimals themselves though, as q1.x == q2.x evaluates to true, as expected.
Is it because isbits(t1) but not isbits(q1)? If so, how is the choice of ==() affected by this? Is there somewhere in the docs where this is explained?
Because == is not explicitly defined on type MyType{T,P} it falls back to:
julia> @less ==(q1,q2)
==(x, y) = x === y
...
therefor false.
There is no implicit == which compares each part of struct. You have to define this for your types, e.g.:
julia> import Base.==
julia> ==(a::MyType{T,P},b::MyType{T,P}) where {T,P} = a.x == b.x && a.y == b.y
== (generic function with 175 methods)
julia> ==(q1,q2)
true
I wouldn’t say that it is because isbits(q1) is false. The type Decimal is because of it’s implementation not a isbitstype and because of it’s implementation === is false in equal values but different variables. But this is somehow esoteric so lets just say:
julia> isbitstype(Decimal)
false
so we expect
julia> Decimal(1) === Decimal(1)
false
I don’t hink it’s somewhere explicit in the docs. Perhaps it helps if you look at the types dump: