# Suddenly qualified Base-types

**URL:** <https://discourse.julialang.org/t/suddenly-qualified-base-types/4292>\
**Category:** General Usage\
**Created:** [June 15, 2017, 10:00pm UTC](https://discourse.julialang.org/t/suddenly-qualified-base-types/4292 "2017-06-15T22:00:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ulysses](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ulysses/32/665_2.png) [@ulysses](https://discourse.julialang.org/u/ulysses)\
**Post date:** [June 15, 2017, 10:00pm UTC](https://discourse.julialang.org/t/suddenly-qualified-base-types/4292/1 "2017-06-15T22:00:59Z")

</div>

Consider the output of `subtypes` function:

```julia
julia> subtypes(Associative)
5-element Array{Union{DataType, UnionAll},1}:
 Base.EnvHash      
 Base.ImmutableDict
 Dict              
 ObjectIdDict      
 WeakKeyDict

```

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?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 16, 2017, 12:30am UTC](https://discourse.julialang.org/t/suddenly-qualified-base-types/4292/2 "2017-06-16T00:30:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bicycle1885](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bicycle1885/32/107_2.png) [@bicycle1885](https://discourse.julialang.org/u/bicycle1885)\
**Post date:** [June 16, 2017, 4:19am UTC](https://discourse.julialang.org/t/suddenly-qualified-base-types/4292/3 "2017-06-16T04:19:25Z")

</div>

This may work as you expect:

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

julia> qualified_name(Int)
"Core.Int64"

julia> qualified_name(Dict)
"Base.Dict{K,V}"

julia> qualified_name(Base.ImmutableDict)
"Base.ImmutableDict{K,V}"

```

Here I use [https://docs.julialang.org/en/stable/stdlib/base/?highlight=reflection#Base.Base.datatype\_module](https://docs.julialang.org/en/stable/stdlib/base/?highlight=reflection#Base.Base.datatype_module).

---

<div class="post-metadata">

**Author:** ![ulysses](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ulysses/32/665_2.png) [@ulysses](https://discourse.julialang.org/u/ulysses)\
**Post date:** [June 16, 2017, 2:20pm UTC](https://discourse.julialang.org/t/suddenly-qualified-base-types/4292/4 "2017-06-16T14:20:15Z")

</div>

@bicycle1885 this is not working with Julia 0.6-rc2

```julia
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:

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

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

```
