Strange result in typeof of a Function

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!

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

1 Like

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.

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.