# How does \`Base.ImmutableDict\` work internally?

**URL:** https://discourse.julialang.org/t/how-does-base-immutabledict-work-internally/74117
**Category:** General Usage
**Tags:** dictionaries
**Created:** [January 6, 2022, 2:12am UTC](https://discourse.julialang.org/t/how-does-base-immutabledict-work-internally/74117 "2022-01-06T02:12:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![wmanning-cra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wmanning-cra/32/30967_2.png) [@wmanning-cra](https://discourse.julialang.org/u/wmanning-cra)
#### Post date: [January 6, 2022, 2:12am UTC](https://discourse.julialang.org/t/how-does-base-immutabledict-work-internally/74117/1 "2022-01-06T02:12:41Z")

</div>

I just discovered `Base.ImmutableDict`, and it appears to be a very strange type. I get the core concept of a linked list of key-value pairs. But the reference to the next node is of type `Base.ImmutableDict{K, V}`. How can an immutable struct contain another instance of itself?

I tried defining a similar struct in the REPL, and to my shock, it was allowed. But I still can’t figure out how to construct an instance of it. The `sizeof()` my struct implies that the self-referential field is 8 bytes, which might mean that it’s stored as a pointer.

Can self-referential immutable structs actually be utilized in normal Julia code, or is there some compiler magic involved with this type?

---

<div class="post-metadata">

### Author: ![dilumaluthge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dilumaluthge/32/29283_2.png) [@dilumaluthge](https://discourse.julialang.org/u/dilumaluthge)
#### Post date: [January 6, 2022, 2:20am UTC](https://discourse.julialang.org/t/how-does-base-immutabledict-work-internally/74117/2 "2022-01-06T02:20:16Z")

</div>

[https://docs.julialang.org/en/v1/manual/constructors/#Incomplete-Initialization](https://docs.julialang.org/en/v1/manual/constructors/#Incomplete-Initialization)
