In the Julia code below, we have equality not working for T{BigInt}, due to BigInt being a mutable struct. == is explicitly defined by BigInt for themselves, however.
julia> struct T{X}
x :: X
end
julia> T{Int64}(1) == T{Int64}(1), T{Int64}(1) === T{Int64}(1)
(true, true)
julia> T{BigInt}(1) == T{BigInt}(1), T{BigInt}(1) === T{BigInt}(1)
(false, false)
julia> T{BigInt}(1).x == T{BigInt}(1).x, T{BigInt}(1).x === T{BigInt}(1).x
(true, false)
Is there a way to either:
- autogenerate an
==for these sorts of structs which just recurses==on each field, - or have immutable versions of mutable structs as members (as with
constin C++), other than using an immutable equivalent toBigInt?
My goal is to avoid boilerplate in a package with a large number of such structs.