Preferred syntax for parametric type aliases in 0.6


#1

When using type aliases to fix some type parameters, is there a difference between:

const MyVec1{T} = Array{T, 1}
const MyVec2{T} = Array{T, 1} where T
const MyVec3 = Array{T, 1} where T

Or if they’re functionally equivalent is one of them preferred? I rather like the MyVec1 definition as it seems most analogous to struct Foo{T} ... end definitions. It also allows you to clearly specify the type parameter order:

julia> const RevArray1{N, T} = Array{T, N}
Array{T,N} where T where N

julia> const RevArray2{N, T} = Array{T, N} where {T, N}
Array{T,N} where N where T

julia> const RevArray3 = Array{T, N} where {T, N}
Array{T,N} where N where T

julia> const RevArray4 = Array{T, N} where {N, T}
Array{T,N} where T where N

julia> RevArray1{1, Int}
Array{Int64,1}

julia> RevArray2{1, Int}
Array{1,Int64}

julia> RevArray3{1, Int}
Array{1,Int64}

julia> RevArray4{1, Int}
Array{Int64,1}

Here RevArray2 seems problematic because the parameter orderings conflict (apparently the where clause wins)


#2

MyVec1 is the preferred syntax surgar for MyVec3. MyVec2 is wrong.