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

Ptr is an alias for Ptr{T} where T, which is a UnionAll. Is this not exactly what you are asking for?

1 Like
julia> subtypes(Ptr)
Type[]

Even though you and I both know it contains arbitrarily many subtypes. That’s all I’m saying.

Perhaps the docstring for subtypes could be improved. My understanding is that it only returns the explicitly declared subtypes of a type. Consider the following code:

abstract type A{T} end
struct B{T} <: A{T} end

A{Int} is not explicitly declared to be a subtype of A, and neither is B{Int}.

julia> A{Int} <: A
true

julia> B{Int} <: A
true

julia> subtypes(A)
1-element Array{Any,1}:
 B

Loosely speaking, the only part of the above definition that is explicitly declared is B <: A. By explicit, I mean it’s what is in the source code.

2 Likes

So what should subtypes(Ptr) return in your opinion?