Something weird is going on with `DenseArray`

From base/boot.jl:

# commented-out definitions are implemented in C

...

#abstract type AbstractArray{T,N} end
#abstract type DenseArray{T,N} <: AbstractArray{T,N} end

...

#mutable struct Array{T,N} <: DenseArray{T,N}
#  ref::MemoryRef{T}
#  size::NTuple{N,Int}
#end

So Array should be a subtype of DenseArray, and DenseArray should be abstract, so not a DataType. But these are apparently not true:

julia> Array{Int,3} isa DenseArray{Int,3}
false

julia> Array{Int,3} isa DenseArray
false

julia> Array isa DenseArray
false

julia> typeof(DenseArray{Int,3})
DataType

Although DenseArray and DenseArray{Int,3} have no constructor methods, as we would expect from an abstract type.

Is this a bug, or is there something I’m missing here?

isa and <: aren’t the same thing.

julia> Array{Int, 3} <: DenseArray{Int,3}
true
2 Likes

oh my god you’re right I’m just being dumb. and apparently DataTypes can be abstract too. I’m just gonna delete this.

FYI, the fact that abstract types usually don’t have (constructor) methods is purely a matter of style/convention. And some abstract types, like AbstractFloat, do have methods.