The Julia style guide says the following:
Don’t use unnecessary static parameters. A function signature:
foo{T<:Real}(x::T) = ...should be written as:
foo(x::Real) = ...
I expected that to apply to array parameters too. However, if I write the following code:
ret1(x::Real) = x
ret2(x::Array{Float64,2}) = x
ret3(x::Array{Real,2}) = x
ret1(1.0)
ret2(rand(2,2))
ret3(rand(2,2))
then I get the following console output (using Julia 0.2.1):
MethodError(ret3,(
2x2 Array{Float64,2}:
0.841121 0.322133
0.469432 0.495438,))
So why does Julia throw an error for arrays with abstract type parameters, but not for variables with abstract types?