Given an “item” value, say v::Union{Type,Function,Module}
. I can easily get its name as a symbolic expression, like:
julia> nameof(v)
:Item
I can also get a string representation with its full-qualified name in the current context, like:
julia> repr(v)
"Main.Path.Of.Nested.Modules.Item"
But can I get this fully qualified name as an expression?
julia> qualified_nameof(v)
:(Main.Path.Of.Nested.Modules.Item)
I am aware that I could just:
qualified_name(v) = Meta.parse(repr(v))
… but that’s an unnecessary roundtrip, right?
I also could leverage parentmodule
:
function qualified_name(v)
name = nameof(v)
parent = parentmodule(v)
v === parent && return name # Root reached.
:($(qualified_name(parent)).$name)
end
… but am I not sort of re-inventing something here? Is there a primitive julia function to do this already?