What is a DataType exactly and why isn't a Vector a DataType?


#1

Topic says it all.
Thanks


#2

An instance of Vector{T} object is an Array{T,1}, but Vector{T} itself is a DataType.

julia> typeof(Vector{Any})
DataType

julia> typeof(Vector{Any}())
Array{Any,1}

julia> typeof(ans)
DataType

#3

I see, then Unions are not DataTypes.

julia> Vector isa DataType
false

julia> Vector{Any} isa DataType
true

#4

Seems you are right,

julia> typeof(Vector) |> supertype
Type{T}

julia> Vector isa Type
true

julia> Vector{Any} isa Type
true

They are of type Type instead of DataType.


#5

Correct; a type like Vector{Int} is a DataType because it has concrete properties like memory layout. Vector on the other hand expresses the union of Vector{T} types for all values of T, so it’s a more abstract concept.