# Anybody else find the new where syntax less than satisfactory?

**URL:** <https://discourse.julialang.org/t/anybody-else-find-the-new-where-syntax-less-than-satisfactory/4897>\
**Category:** General Usage\
**Created:** [July 17, 2017, 9:39am UTC](https://discourse.julialang.org/t/anybody-else-find-the-new-where-syntax-less-than-satisfactory/4897 "2017-07-17T09:39:25Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [July 18, 2017, 1:49am UTC](https://discourse.julialang.org/t/anybody-else-find-the-new-where-syntax-less-than-satisfactory/4897/14 "2017-07-18T01:49:04Z")

</div>

I explained the overall motivation for the `where` syntax in this StackOverflow answer:

> <https://stackoverflow.com/questions/41931289/where-in-function-definitions-in-julia-0-6/41940710#41940710>

Partly quoting from there (with some clarifications and edits):

Fundamentally, the problem with `F{T}(args...)` in Julia 0.5 and earlier is that the `F{T}` part is ambiguous – the parser knows what it means from the broader context, but its meaning depends heavily on that context. The fact that it can mean such different things is pretty confusing:

- In most contexts, `F{T}` means the parametric type `F` with type parameter `T`.
- Followed by parens in most contexts, `F{T}(args...)` means to apply the type `F{T}` to the arguments `args...` as a function, typically constructing an instance of the type `F{T}`.
- Followed by parens as the left hand side of a method definition, however, as in `F{T}(args...) = expr`, it means to define a method for `F` as a function, with type parameters `T`, formal arguments `args...`, and definition `expr`.

This motley collection of different meanings is not ideal. Indeed, constructor syntax, where these syntaxes collide, was, in my opinion, prior to 0.6, the worst, most confusing part of Julia. Moreover, there were no syntaxes for either of these meanings, both of which can be useful:

- Adding a method to `F{T}` for the concrete value of `T` in the current scope.
- Adding a method to `F{T}` for each parametric value `T`.

The former was previously only possible by assigning a name to `F{T}` and then adding a method to that. The latter was only possible inside of the parametric type block, where `F` by itself was (and still is when you use the deprecated syntax) magically bound to each specific `F{T}` when used as the function name in a method definition. 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.

---

_[View the full topic](https://discourse.julialang.org/t/anybody-else-find-the-new-where-syntax-less-than-satisfactory/4897)._
