The new syntax means the same thing but can be used in more circumstances and can express more constructs and eliminates a number of conceptual ambiguities, especially surrounding parametric constructors. The old syntax will be deprecated in 0.6 and some of the old syntax will be reclaimed with different meaning in 1.0. Fundamentally, the problem with F{T}(args...) is that the F{T} part is conceptually ambiguous – the parser knows what it means, but it’s often confusing to humans:
-
In isolation
F{T}means the parametric typeFwith type parameterT. -
Followed by parens, not as part of a method definition,
F{T}(args...)means to apply the typeF{T}to the argumentsargs...as a function, typically constructing an instance of the typeF{T}. -
Followed by parens and equals, i.e. as part of a method definition as in
F{T}(args...) = expr, it means to define a method forFas a function, with type parametersTformal argumentsargs...and definitionexpr.
In particular, there is no syntax for either of these:
-
Adding a method to
F{T}for the concrete value ofTin the current scope. -
Adding a method to
F{T}for each parametric valueT.
This situation causes constructor syntax in Julia 0.5 and prior to be more confusing and unintuitive than necessary. In Julia 1.0 type parameters and constructors will be both more intuitive and consistent, following these principles:
- The syntax used to define a method always matches the syntax used to call it.
- The
F{T}syntax always refers to the typeFwith parameterT. - Type parameters are always introduced by
whereclauses.
There will be a more detailed explanation of the changes when 0.6 comes out, probably in a blog post on highlights of the 0.6 release.