Today I learned:
julia> struct S{A,B} end
julia> s = S{Int, Float64}()
S{Int64, Float64}()
julia> s isa S{Int}
true
julia> s isa S{Float64}
false
So I can drop trailing parameter specifications from a composite type and “automatically” generate an abstract type? Is this in the documentation anywhere?
Here it’s (More about types · The Julia Language) .
This indicates that Array
actually names a UnionAll
type. There is one UnionAll
type for each parameter, nested. The syntax Array{Int,2}
is equivalent to Array{Int}{2}
; internally each UnionAll
is instantiated with a particular variable value, one at a time, outermost-first. This gives a natural meaning to the omission of trailing type parameters; Array{Int}
gives a type equivalent to Array{Int,N} where N
.