What is the main point of "where"?

I believe it’s intended to create a distinction between a parametric type’s constructor:

Array{T}(x) where {T} = ...

which can be called with an explicit parameter:

x = Array{Float64}(5)

and a regular method:

f(x::T) where {T} = ...

which cannot:

x = f(1.0)

and just as a way to talk about unbound type parameters in a more concrete way. For example, on julia v0.5 we have:

julia> Vector
Array{T,1}

but on julia v0.6 we have:

julia> Vector
Array{T,1} where T

which clearly shows that the T is not yet bound to anything.

1 Like