Does the example below from Types chapter of Julia manual depend on Real <: Real
being true? I’m assuming that author’s intention was to include the first definition of norm
in more generic definition, which follows.
Since Point{Float64} is not a subtype of Point{Real}, the following method can’t be applied to arguments of type Point{Float64}:
function norm(p::Point{Real}) sqrt(p.x^2 + p.y^2) end
The correct way to define a method that accepts all arguments of type Point{T} where T is a subtype of Real is:
function norm{T<:Real}(p::Point{T}) sqrt(p.x^2 + p.y^2) end