# Type declaration in function definition

**URL:** <https://discourse.julialang.org/t/type-declaration-in-function-definition/60075>\
**Category:** New to Julia\
**Created:** [April 27, 2021, 2:27am UTC](https://discourse.julialang.org/t/type-declaration-in-function-definition/60075 "2021-04-27T02:27:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [April 27, 2021, 2:27am UTC](https://discourse.julialang.org/t/type-declaration-in-function-definition/60075/1 "2021-04-27T02:27:24Z")

</div>

Perhaps I’m wrong, but I think there was a time when defining functions like `f(x::Real) = ...` was discouraged because of performance reasons. Instead, people were told to use `f(x::T) where {T <: Real} = ...`. Yet, I see the use of the former form in some packages that should be very performant. Are these two forms now similar in performance?

---

<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:** [April 27, 2021, 2:37am UTC](https://discourse.julialang.org/t/type-declaration-in-function-definition/60075/2 "2021-04-27T02:37:25Z")

</div>

`f(x::Real)` hasn’t had any problems since at least 0.6. The place where specific type annotations matter is in struct definitions. Functions specialize automatically on the types of their inputs.

---

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [April 27, 2021, 2:49am UTC](https://discourse.julialang.org/t/type-declaration-in-function-definition/60075/3 "2021-04-27T02:49:03Z")

</div>

I guess my last big project in Julia was with version 0.4-0.5. Great to know that there is no need to worry about those annotations now.
