Suddenly qualified Base-types


Consider the output of subtypes function:

julia> subtypes(Associative)
5-element Array{Union{DataType, UnionAll},1}:

What is the reason of having some types with Base-prefix, and others – without? Can I control this somehow? I use subtype to traverse type hierarchy for doing various analysis, and I would like to have consistency: either all types are prefixed with the package name or none of them are. Is it possible?


I believe it is because some of those names are exported from Base and the others are not.


This may work as you expect:

julia> function qualified_name(typ)
           return string(Base.datatype_module(typ), ".", split(string(typ), ".")[end])

julia> qualified_name(Int)

julia> qualified_name(Dict)

julia> qualified_name(Base.ImmutableDict)

Here I use


@bicycle1885 this is not working with Julia 0.6-rc2

ERROR: MethodError: no method matching datatype_module(::Type{Dict})
Closest candidates are:
  datatype_module(::DataType) at reflection.jl:160

Did you try it? Which Julia version?

UPD: this worked for me:

get_datatype(t :: DataType) = t
get_datatype(t :: UnionAll) = Base.unwrap_unionall(t)

function qualified_name(t)
    base = split("$(t)", ".")[end]