# Is there a difference between function my\_func(x::SomeAbstractType) and my\_func(x::T) where T \<: SomeAbstractType

**URL:** <https://discourse.julialang.org/t/is-there-a-difference-between-function-my-func-x-someabstracttype-and-my-func-x-t-where-t-someabstracttype/19793>\
**Category:** General Usage\
**Created:** [January 18, 2019, 7:10pm UTC](https://discourse.julialang.org/t/is-there-a-difference-between-function-my-func-x-someabstracttype-and-my-func-x-t-where-t-someabstracttype/19793 "2019-01-18T19:10:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![philip](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/philip/32/17191_2.png) [@philip](https://discourse.julialang.org/u/philip)\
**Post date:** [January 18, 2019, 7:10pm UTC](https://discourse.julialang.org/t/is-there-a-difference-between-function-my-func-x-someabstracttype-and-my-func-x-t-where-t-someabstracttype/19793/1 "2019-01-18T19:10:13Z")

</div>

It doesn’t look like it based on output from `@code_lowered` and `@code_native`, but I also didn’t [read](https://docs.julialang.org/en/latest/manual/types/#Abstract-Types-1) that these are explicitly equivalent. Clearly they are not equivalent in the case of some containing type (e.g. `Point{T} where T<:Real` and `Point{Real}` are not the same) but are they equivalent otherwise? If so, is one preferred? If not, what is the difference?

```julia
abstract type SomeAbstractType end

struct ConcreteType <: SomeAbstractType
    field1::Float64
end

function my_func_v1(x::SomeAbstractType)
    x.field1 + 1.0
end

function my_func_v2(x::T) where T <: SomeAbstractType
    x.field1 + 1.0
end

```

```julia
julia> @code_lowered my_func_v1(ConcreteType(1.0))
CodeInfo(
xyz 1 ─ %1 = (Base.getproperty)(x, :field1) │
    │ %2 = %1 + 1.0 │
    └── return %2 

julia> @code_lowered my_func_v2(ConcreteType(1.0))
CodeInfo(
xyz 1 ─ %1 = (Base.getproperty)(x, :field1) │
    │ %2 = %1 + 1.0 │
    └── return %2 │
)

```

---

<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 18, 2019, 7:43pm UTC](https://discourse.julialang.org/t/is-there-a-difference-between-function-my-func-x-someabstracttype-and-my-func-x-t-where-t-someabstracttype/19793/2 "2019-01-18T19:43:52Z")

</div>

There is no functional difference, but as a matter of style, you should use the first version in function signatures, unless you have need of `T` inside the body. Even then you can use `typeof`.
