Why is Module concrete?

There’s another problem with nameof — and that’s that it isn’t unique:

julia> module Algebra
           module Internals
           end
       end
Main.Algebra

julia> module SocialStudies
           module Internals
           end
       end
Main.SocialStudies

julia> nameof(Algebra.Internals)
:Internals

julia> nameof(SocialStudies.Internals)
:Internals

Now, as to why Val{x}() is expensive, this really gets to the crux of what I put as your “second question”. In short, Val{x} and types like it put values into the type domain. This is an inherently type unstable operation unless the value itself is a constant. Now, depending upon the downstream operations, you can sometimes recoup the cost. This is likely one aspect to the answer about why typeof(Base) == typeof(Core):

4 Likes