# Why is Module concrete?

**URL:** https://discourse.julialang.org/t/why-is-module-concrete/51877
**Category:** Internals & Design
**Created:** [December 15, 2020, 3:06pm UTC](https://discourse.julialang.org/t/why-is-module-concrete/51877 "2020-12-15T15:06:15Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [December 15, 2020, 5:08pm UTC](https://discourse.julialang.org/t/why-is-module-concrete/51877/7 "2020-12-15T17:08:35Z")

</div>

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

```Julia
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)`:

> [@Overhead of dynamic dispatch?](https://discourse.julialang.org/t/overhead-of-dynamic-dispatch/7089/5):
>
> There are a number of downsides to encoding a property of your thing in the type system: There will be more time spent in compilation — every time a different type hits a different function, Julia will compile a new specialized version just for that type. If this property is typically determined by a run-time value, then many functions working with your things will be type-unstable. Type-unstable variables can stymie optimizations, cause allocations and hit dynamic dispatch. Collections of ma…

---

_[View the full topic](https://discourse.julialang.org/t/why-is-module-concrete/51877)._
