Continuing the discussion from A precise definition of what it means to be an instance of an abstract type:
The following appears to contradict the claim <: means “is a subtype of” that appears in the manual (Types · The Julia Language).
julia> subtypes(Ptr)
Type[]
julia> Ptr{Float64} <: Ptr
true
I think the manual is in need of correction because it also states:
And of course, all specific pointer types are subtypes of the umbrella
Ptrtype:
Note that, unless we the function supertypes also disagrees with <: here since
julia> supertypes(Ptr{Float64})
(Ptr{Float64}, Ref{Float64}, Any)
julia> supertypes(Ptr)
(Ptr, Ref{T} where T, Any)
Any suggestions on how to reconcile? Is this specific to parametric types, and if so, then is Type a parametric type?
julia> Type{Float64} <: Type
true
julia> supertypes(Type{Float64})
(Type{Float64}, Any)
I am leaning towards the following reconciliation: Ptr{Float64} is a parametric instance of Ptr, but not a type instance or a subtype. This would fit Types · The Julia Language :
types can take parameters, so that type declarations actually introduce a whole family of new types – one for each possible combination of parameter values.
Parametric instances are then “subnodes” of the parametric type.
But, since <: picks this up, Ptr{Float64} <: Ptr does not really mean “Ptr{Float64} is a subtype of Ptr”. Instead, it is simply ensuring that Ptr{Float64} inherits the properties of Ptr. Would it not make more sense to put both parametric instance and parametric type at the same level of <:, so that
Ptr <: Ptr{Float64} also holds? There is a weak precedent in
julia> Int <: Int64
true
julia> Int64 <: Int
true