Julia types

The whole history can be reconstructed from various discussions linked here. I haven’t read everything, but this explanation is a good one-stop.

Let me quote an excerpt from Stefan’s explanation:

In Julia 1.0, on the other hand, type parameters and constructors will be thoroughly consistent, following these general principles uniformly:

  • The syntax used to define a method always matches the syntax used to call it.
  • The F{T} syntax always refers to the type F with parameter value T .
  • Type parameters are always introduced by where clauses.

I think these principles make the syntax and semantics of parametric types and methods far more understandable and intuitive. Given these principles, semantics like what we now have seem inevitable. The only real question is syntax – and what syntax to use was one of the biggest bikesheds around this issue. I wasn’t initially thrilled with the postfix where syntax, but it’s grown on me and now it seems quite natural. The only really odd case, as you mention, is f(...) where T = body without any type bound, but I’ve found that even this case fairly quickly loses its unfamiliarity. Other keywords than where were discussed, including forall and . However, Julia’s “union all” types are not universally quantified types (they’re actually closer to existentially quantified types), so both of these choices would have been actively at odds with existing type theory nomenclature. The where keyword was the most evocative choice proposed that didn’t clash with well-established terminology. Finally, having the where clause on the right just seemed to read much more naturally in the vast majority of usages.

2 Likes