# Functions and code\_warntype

**URL:** <https://discourse.julialang.org/t/functions-and-code-warntype/16734>\
**Category:** General Usage\
**Tags:** type, parametric-types\
**Created:** [October 24, 2018, 1:13pm UTC](https://discourse.julialang.org/t/functions-and-code-warntype/16734 "2018-10-24T13:13:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [October 24, 2018, 1:13pm UTC](https://discourse.julialang.org/t/functions-and-code-warntype/16734/1 "2018-10-24T13:13:09Z")

</div>

I am puzzled how functions are handled by type inference. There doesn’t seem to be a type `Function{InputType, ReturnType}` to help type inference, instead there is a `typeof(f)` Type. Why is that? I am happy if you point me where to read up on this.

```julia
julia> h(f::Function, x) = f(x)
h (generic function with 1 method)

julia> code_warntype(h, (Function, Int))
Body::Any
1 1 ─ %1 = (f)(x)::Any │
  └── return %1 │

julia> @code_warntype h(abs, 3)
Body::Int64
1 1 ─ %1 = (Base.flipsign_int)(x, x)::Int64 │╻╷ abs
  └── return %1 │  

julia> @macroexpand @code_warntype h(abs, 3)
:((InteractiveUtils.code_warntype)(h, (Base.typesof)(abs, 3)))

julia> typeof(abs)
typeof(abs)

julia> code_warntype(h, (typeof(abs), Int))
Body::Int64
1 1 ─ %1 = (Base.flipsign_int)(x, x)::Int64 │╻╷ abs
  └── return %1   

```

---

<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:** [October 24, 2018, 1:24pm UTC](https://discourse.julialang.org/t/functions-and-code-warntype/16734/2 "2018-10-24T13:24:33Z")

</div>

> [@gdkrmr](#):
>
> There doesn’t seem to be a type `Function{InputType, ReturnType}` to help type inference

You may find discussions about _arrow types_ interesting (search the discussions, also older ones in Google Groups).

---

<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 24, 2018, 1:31pm UTC](https://discourse.julialang.org/t/functions-and-code-warntype/16734/3 "2018-10-24T13:31:45Z")

</div>

Check Jeff’s thesis: [https://dspace.mit.edu/bitstream/handle/1721.1/99811/927297147-MIT.pdf?sequence=1](https://dspace.mit.edu/bitstream/handle/1721.1/99811/927297147-MIT.pdf?sequence=1)
