-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
I was confused about the meaning of parametric singleton types such as Type{Array{T}}, and the manual section "Singleton Types" does not say anything about them. It should be improved.
The only documentation section I could find that says anything about parametric singleton types is "Case Study: Rational Conversions", which is misleading because it defines methods for convert{T<:Int}(::Type{Rational{T}}, x::...) but not convert(::Type{Rational}, x::...). At first glance it seems like convert(Rational, x) would invoke one of those Type{Rational{T}} methods just as convert(Rational{Int8}, x) would. In fact convert(Rational, x) invokes a method which is not in this documentation section. The convert methods for rational numbers in base/rational.jl are somewhat different from what the documentation says.
Here's a simple example: define f{T}(::Type{Array{T}}) = 1 then f(Array{Int}) invokes that method but f(Array) and f(Array{Int,1}) do not. This makes perfect sense when you think about it, but it isn't really obvious and some specific documentation would help.
BTW unlike the 0.2 version, in the latest version manual on docs.julialang.org the section "Singleton Types" does not show up in the table of contents at all. I am not sure what the problem is. It can be found by going to "Parametric Types" in the table of contents and then scrolling down a long way.