# TypeMapLevel

**URL:** <https://discourse.julialang.org/t/typemaplevel/6609>\
**Category:** Internals & Design\
**Created:** [October 22, 2017, 2:41pm UTC](https://discourse.julialang.org/t/typemaplevel/6609 "2017-10-22T14:41:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [October 22, 2017, 2:41pm UTC](https://discourse.julialang.org/t/typemaplevel/6609/1 "2017-10-22T14:41:24Z")

</div>

Can anyone give a brief overview of `TypeMapLevel`? I hit one in a `m.specializations` field of a `m::Method`. The fieldnames of `TypeMapLevel` seem a bit inscrutable, and from the couple of comments in `julia.h` I’m not really getting it.

---

<div class="post-metadata">

**Author:** ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)\
**Post date:** [October 23, 2017, 2:42pm UTC](https://discourse.julialang.org/t/typemaplevel/6609/2 "2017-10-23T14:42:45Z")

</div>

The TypeMapLevels form a trie-like structure. The TypeMapLevel at depth N splits the trie based on the type of argument in position N. In the code and header file this N is also called an “offset”.

The field `arg1` I think is misnamed at this point — it’s just a hash table that maps the type at position N to the right child node (either a TypeMapEntry or another TypeMapLevel). `targ` is the same but for types of the form `Type{T}`. `linear` is a linked list of entries, used when it’s not worth doing any more trie splitting, and for types that can’t be hashed. The `any` field is used when the type at position N is `Any`.

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [October 24, 2017, 2:02am UTC](https://discourse.julialang.org/t/typemaplevel/6609/4 "2017-10-24T02:02:05Z")

</div>

> The field arg1 I think is misnamed at this point

I read it as “one argument”, as in “a tree-split over one argument that has a single possible type” (no subtypes). But I agree this isn’t the most straightforward name anymore.
