"where" - where?

It is allowed inside.
If inside, you wont have access to the parameter inside the function. You do if outside.
Compare

function f(x::Vector{T} where T <: Real)
  out = zero(T)
  for x_i ∈ x
    out += x_i
  end
  out
end
function g(x::Vector{T} where T <: Real)
  out = zero(eltype(x))
  for x_i ∈ x
    out += x_i
  end
  out
end

function h(x::Vector{T}) where {T <: Real}
  out = zero(T)
  for x_i ∈ x
    out += x_i
  end
  out
end

Running these:

julia> x = randn(20);

julia> sum(x)
-0.8093970114745281

julia> f(x)
ERROR: UndefVarError: T not defined
Stacktrace:
 [1] f(::Array{Float64,1}) at ./REPL[16]:2

julia> g(x)
-0.8093970114745275

julia> h(x)
-0.8093970114745275
3 Likes