# Deprecated syntax parametric method syntax with type of output

**URL:** <https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867>\
**Category:** General Usage\
**Created:** [October 4, 2018, 11:27am UTC](https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867 "2018-10-04T11:27:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FemtoTrader](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/femtotrader/32/309_2.png) [@FemtoTrader](https://discourse.julialang.org/u/FemtoTrader)\
**Post date:** [October 4, 2018, 11:27am UTC](https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867/1 "2018-10-04T11:27:56Z")

</div>

Hello,

I’m fixing some Julia 0.6 code to Julia 0.7/1.0

```julia
short{T<:Real}(qty::T)::T = qty

```

I was trying

```julia
julia> short(qty::T)::T where {T<:Real} = qty
ERROR: UndefVarError: T not defined
Stacktrace:
 [1] top-level scope at none:0

```

I fixed it using

```julia
short(qty::T) where {T<:Real} = qty

```

I wonder why I can’t define T as a parametric type of output like this.

Any idea?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [October 4, 2018, 11:31am UTC](https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867/2 "2018-10-04T11:31:40Z")

</div>

This works (as long as you don’t need `T` in the function body):

```julia
julia> short(qty::T where T<:Real)::T = qty                                                                                                                             
short (generic function with 1 method)                                                                                                                                 

```

Edit: scrap that:

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

```

because the return type declaration is “in the body”.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [October 4, 2018, 11:58am UTC](https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867/3 "2018-10-04T11:58:25Z")

</div>

You need to be a bit more explicit in this case:

```julia
julia> (short(qty::T)::T) where {T<:Real} = qty
short (generic function with 1 method)

julia> short(3)
3

```

Your definition is ambigous and could be parsed as `short(qty::T)::(T where {T<:Real}) = qty`, which would leave the first `T` undefined.

---

<div class="post-metadata">

**Author:** ![FemtoTrader](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/femtotrader/32/309_2.png) [@FemtoTrader](https://discourse.julialang.org/u/FemtoTrader)\
**Post date:** [October 4, 2018, 12:00pm UTC](https://discourse.julialang.org/t/deprecated-syntax-parametric-method-syntax-with-type-of-output/15867/4 "2018-10-04T12:00:45Z")

</div>

Thanks @pfitzseb for your help
