Counterexamples to the interpretation `<:` means "is a subtype of"

In my opinion, there is nothing to reconcile: <: is the subtyping relation and subtypes(T) and supertypes(T) simply don’t show you all objects for which S <: T or T <: S holds, because that’s not possible in general. How would they accomplish that? Both subtypes and supertypes would need to return arrays with an infinite number of elements in that case. For example, subtypes(Ptr) would have to return an array containing Ptr{Float64}, Ptr{String}, Ptr{Ptr{String}}, … really all Ptr{T} for every possible T. And supertypes(Float64) would have to return Union{Float64, String}, Union{Float64, Nothing}, … also infinitely many values. Therefore, they are not useful for determining actual subtyping relations (except in some cases), that’s what <: is for.

7 Likes