In Julia, I most often see code written like fun(n::T) where T<:Integer
, when the function works for all subtypes of Integer
. But sometimes, I also see fun(n::Integer)
, which some guides claim is equivalent to the above, whereas others say it's less efficient because Julia doesn't specialize on the specific subtype unless the subtype T is explicitly referred to.
The latter form is obviously more convenient, and I'd like to be able to use that if possible, but are the two forms equivalent? If not, what are the practicaly differences between them?