# Strange result in typeof of a Function

**URL:** <https://discourse.julialang.org/t/strange-result-in-typeof-of-a-function/17832>\
**Category:** New to Julia\
**Created:** [November 21, 2018, 8:35pm UTC](https://discourse.julialang.org/t/strange-result-in-typeof-of-a-function/17832 "2018-11-21T20:35:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeLenz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/codelenz/32/3419_2.png) [@CodeLenz](https://discourse.julialang.org/u/CodeLenz)\
**Post date:** [November 21, 2018, 8:35pm UTC](https://discourse.julialang.org/t/strange-result-in-typeof-of-a-function/17832/1 "2018-11-21T20:35:53Z")

</div>

Hi.

Is it a bug ?

> julia\> function f(x)  
> x+1  
> end  
> f (generic function with 1 method)
> 
> julia\> typeof(f)  
> typeof(f)
> 
> julia\> isa(f,Function)  
> true

I would expect `Function` as result of typeof(f).

Running

> Julia Version 1.0.2  
> Commit d789231e99 (2018-11-08 20:11 UTC)  
> Platform Info:  
> OS: Linux (x86\_64-pc-linux-gnu)

Thanks!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 21, 2018, 8:41pm UTC](https://discourse.julialang.org/t/strange-result-in-typeof-of-a-function/17832/2 "2018-11-21T20:41:54Z")

</div>

> [@CodeLenz](#):
>
> Is it a bug ?

No, every function has its own type, with `Function` as its supertype.

---

<div class="post-metadata">

**Author:** ![CodeLenz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/codelenz/32/3419_2.png) [@CodeLenz](https://discourse.julialang.org/u/CodeLenz)\
**Post date:** [November 21, 2018, 8:46pm UTC](https://discourse.julialang.org/t/strange-result-in-typeof-of-a-function/17832/3 "2018-11-21T20:46:04Z")

</div>

Thanks @fredrikekre  
The command `typeof(f)` is returning `typeof(f)`. It is really strange for a beginner. I understand that DataType could be also a valid output ?

I now see that the correct behaviour here is to inform the return type of the function: `typeof(f(1))` should return an Int64.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [November 21, 2018, 9:01pm UTC](https://discourse.julialang.org/t/strange-result-in-typeof-of-a-function/17832/4 "2018-11-21T21:01:39Z")

</div>

> [@CodeLenz](#):
>
> The command `typeof(f)` is returning `typeof(f)`

It returns type of `f` but simply `show(typeof(f))` if `f` is a function is defined to print `typeof(f)` string in this case. You can check it in the definition of `show_type_name` function in file show.jl that this is the case.
