New Julia user here. Trying to understand the benefit of this:
function test(p::Float64,x::Int) :: Float64
<do something>
end
over the more pythonic:
function test(p,x)
<do something>
end
The same question could be asked of composite types. Is this:
struct myStruct{T<:Real}
x::T
y::T
better than this:
struct myStruct
x::Float64
y::Float64
or this:
struct myStruct
x
y
My stab at an answer:
1- Declaring the return type for a function should improve performance because the compiler will know the type of the return value.
2- Declaring the types of the inputs shouldn’t improve performance necessarily. Each time this function is called with new (different) parameter types, it will compile a version of the function for that particular set of inputs. Leaving the types off of the input arguments makes the function more general and Julia will optimize on the fly.