# Current differences in ::T vs T where T

**URL:** <https://discourse.julialang.org/t/current-differences-in-t-vs-t-where-t/19231>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 3, 2019, 9:42am UTC](https://discourse.julialang.org/t/current-differences-in-t-vs-t-where-t/19231 "2019-01-03T09:42:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nosferican](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nosferican/32/9275_2.png) [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Post date:** [January 3, 2019, 9:42am UTC](https://discourse.julialang.org/t/current-differences-in-t-vs-t-where-t/19231/1 "2019-01-03T09:42:50Z")

</div>

I was asked what was the current status of the differences between,

```julia
magic(obj::Any) = zero(typeof(obj))

```

and

```julia
magic(obj::T) where T = zero(T)

```

I believe in 0.6 there were some issues being worked out with performance degradation using `where T`, but I am not aware of the current status. I usually use `::` and leave `T` when it is absolutely necessary.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 3, 2019, 10:05am UTC](https://discourse.julialang.org/t/current-differences-in-t-vs-t-where-t/19231/2 "2019-01-03T10:05:39Z")

</div>

I don’t recall what the issue was, but they should be equivalent. Also, the `::Any` is not necessary.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [January 3, 2019, 10:23am UTC](https://discourse.julialang.org/t/current-differences-in-t-vs-t-where-t/19231/3 "2019-01-03T10:23:29Z")

</div>

Semantically they are the same. However AFAIU if `obj::Function` then there is a heuristic, that `::Any` will only specialized if `obj` is called in the body of `magic`. The `where` version will specialize anyway.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [January 3, 2019, 10:25am UTC](https://discourse.julialang.org/t/current-differences-in-t-vs-t-where-t/19231/4 "2019-01-03T10:25:01Z")

</div>

You can experiment:

```julia
julia> foo(x::Any) = 1
foo (generic function with 1 method)

julia> foo(x::T) where {T} = 2
foo (generic function with 1 method) # <- overwrites the old definition

julia> foo(x::T) where {T<:Integer} = 2
foo (generic function with 2 methods) # <- makes a new method

```

And:

```julia
julia> T where T
Any

```
