# "where" - where?

**URL:** <https://discourse.julialang.org/t/where-where/5188>\
**Category:** General Usage\
**Created:** [August 2, 2017, 6:13pm UTC](https://discourse.julialang.org/t/where-where/5188 "2017-08-02T18:13:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen\_Vavasis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephen_vavasis/32/3389_2.png) [@Stephen\_Vavasis](https://discourse.julialang.org/u/Stephen_Vavasis)\
**Post date:** [August 2, 2017, 6:13pm UTC](https://discourse.julialang.org/t/where-where/5188/1 "2017-08-02T18:13:51Z")

</div>

The following quote is an excerpt from the latest version of the manual:

(Equivalently, one could define `function norm{T<:Real}(p::Point{T})` or `function norm(p::Point{T} where T<:Real)`; see UnionAll Types.)

Notice how the `where` clause lies inside the parentheses specifying the function arguments in this example. Elsewhere in the manual, the `where` clause always seems to be after the parentheses. Is this a typo in the manual, or is the where-clause allowed inside? Is there a distinction in meaning for inside versus outside? I tried to put the where-clause inside the parentheses (next to the parameterized argument) in my own code. I didn’t get a syntax error, but I did get an error at run-time about an undefined type.

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [August 2, 2017, 6:20pm UTC](https://discourse.julialang.org/t/where-where/5188/2 "2017-08-02T18:20:59Z")

</div>

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

```julia
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
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

```
