Constant type semantics

I think in this instance they are equivalent. consider

julia> Point3{T} = Point{T, 3}
Point{T,3} where T

julia> Point3 = 11
ERROR: invalid redefinition of constant Point3
Stacktrace:
 [1] top-level scope at REPL[25]:1

thus Point3 is implicitly made a const. However, if you don’t have type parameters, then you should use the const:

julia> Point3I = Point{Int, 3}
Point{Int64,3}

julia> Point3I = 11
11

as then the variable is not automatically marked as const, and thus if you use it inside functions it will lead to type-unstable code.

To make the notation consistent, I would then also use const in the first example, even though it is not needed.

2 Likes