# Where does where go?

**URL:** <https://discourse.julialang.org/t/where-does-where-go/32570>\
**Category:** General Usage\
**Created:** [December 22, 2019, 12:46am UTC](https://discourse.julialang.org/t/where-does-where-go/32570 "2019-12-22T00:46:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [December 22, 2019, 12:46am UTC](https://discourse.julialang.org/t/where-does-where-go/32570/1 "2019-12-22T00:46:49Z")

</div>

I generally write function signatures with the where-clause outside of the arguments list. Is there any reason why one would put that inside the function signature? e.g.

```julia
foo(x::T where T) = 1
foo(x::T) where T = 2
foo(1) # 2

```

But then they seem to be equivalent as it reports only 1 method:

```julia
julia> foo
foo (generic function with 1 method)

```

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [December 22, 2019, 12:52am UTC](https://discourse.julialang.org/t/where-does-where-go/32570/2 "2019-12-22T00:52:44Z")

</div>

It makes a difference for something like

```
foo(x::T where T, y::T where T)
foo(x::T, y::T) where T

```

The first takes any 2 arguments of any types, while in the 2nd, the 2 arguments need to have the same type.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 22, 2019, 5:03am UTC](https://discourse.julialang.org/t/where-does-where-go/32570/3 "2019-12-22T05:03:39Z")

</div>

It also matters if you want to use the type `T` in the function body:

```julia
julia> f(::T where T) = T
f (generic function with 1 method)

julia> f(1)
ERROR: UndefVarError: T not defined
Stacktrace:
 [1] f(::Int64) at ./REPL[1]:1
 [2] top-level scope at REPL[2]:1

julia> f(::T) where T = T
f (generic function with 1 method)

julia> f(1)
Int64

```

---

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [December 22, 2019, 5:33am UTC](https://discourse.julialang.org/t/where-does-where-go/32570/4 "2019-12-22T05:33:54Z")

</div>

This is

```julia
f :: (T -> T) where T
f :: (T where T) -> T 

```

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [December 24, 2019, 2:57am UTC](https://discourse.julialang.org/t/where-does-where-go/32570/5 "2019-12-24T02:57:55Z")

</div>

Hi @thautwarm - what do you mean?

---

<div class="post-metadata">

**Author:** ![thautwarm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thautwarm/32/37760_2.png) [@thautwarm](https://discourse.julialang.org/u/thautwarm)\
**Post date:** [December 25, 2019, 6:26am UTC](https://discourse.julialang.org/t/where-does-where-go/32570/6 "2019-12-25T06:26:27Z")

</div>

Hi, I meant the scope of the fresh type variable.  
Technically, `where` is the same thing as the `forall` quantifier.  
Check [this wiki subsection](https://en.wikipedia.org/wiki/Quantifier_(logic)#Formal_semantics) for more about the scope.
