# Design of register\_kinds! in JuliaSyntax.jl/src/julia/kinds.jl

**URL:** <https://discourse.julialang.org/t/design-of-register-kinds-in-juliasyntax-jl-src-julia-kinds-jl/138567>\
**Category:** Internals & Design\
**Tags:** juliasyntax\
**Created:** [August 2, 2026, 10:37am UTC](https://discourse.julialang.org/t/design-of-register-kinds-in-juliasyntax-jl-src-julia-kinds-jl/138567 "2026-08-02T10:37:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liinyun](https://avatars.discourse-cdn.com/v4/letter/l/91b2a8/32.png) [@liinyun](https://discourse.julialang.org/u/liinyun)\
**Post date:** [August 2, 2026, 10:37am UTC](https://discourse.julialang.org/t/design-of-register-kinds-in-juliasyntax-jl-src-julia-kinds-jl/138567/1 "2026-08-02T10:37:17Z")

</div>

“”"  
register\_kinds!(mod, module\_id, names)

Register custom `Kind`s with the given `names`, belonging to a module `mod`.  
`names` is an array of arbitrary strings.

In order for kinds to be represented by a small number of bits, some nontrivial  
cooperation is required between modules using custom kinds:

- The integer `module_id` is globally unique for each `mod` which will be used  
together, and not larger than $\_kind\_module\_id\_max.
- No two modules register the same `name`. The semantics of a given `kind` name  
should be defined by the module which owns it.

To allow ranges of kinds to be delimited and quickly tested for, some special  
names are allowed: `BEGIN_section` and `END_section` pairs are detected, and  
alias the next and previous kind id’s respectively so that kinds in `section`  
can be tested with `BEGIN_section <= k <= END_section`.  
“”"  
function register\_kinds!(mod, module\_id, names)  
\_register\_kinds!(\_kind\_modules, \_kind\_int\_to\_str, \_kind\_str\_to\_int, mod, module\_id, names)  
end

I’m confused why should other module use this function to register kinds. Isn’t this function private? Shouldn’t kinds be hardcoded in the compiler?

---

<div class="post-metadata">

**Author:** ![penelopeysm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/penelopeysm/32/213172_2.png) [@penelopeysm](https://discourse.julialang.org/u/penelopeysm)\
**Post date:** [August 2, 2026, 11:17am UTC](https://discourse.julialang.org/t/design-of-register-kinds-in-juliasyntax-jl-src-julia-kinds-jl/138567/2 "2026-08-02T11:17:54Z")

</div>

If you see [julia/JuliaSyntax/src/julia/kinds.jl at a6567e17f63af24909edfe54cbf2a41c4165b308 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/a6567e17f63af24909edfe54cbf2a41c4165b308/JuliaSyntax/src/julia/kinds.jl#L29-L33) it describes a couple other modules which also register kinds. One is JuliaLowering, [julia/JuliaLowering at a6567e17f63af24909edfe54cbf2a41c4165b308 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/tree/a6567e17f63af24909edfe54cbf2a41c4165b308/JuliaLowering) and one is JuliaSyntaxFormatter, [GitHub - c42f/JuliaSyntaxFormatter.jl: Semantic highlighting of JuliaSyntax ASTs as Julia code · GitHub](https://github.com/c42f/JuliaSyntaxFormatter.jl/tree/main)

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [August 2, 2026, 9:20pm UTC](https://discourse.julialang.org/t/design-of-register-kinds-in-juliasyntax-jl-src-julia-kinds-jl/138567/3 "2026-08-02T21:20:16Z")

</div>

Also see [WIP/RFC: Add extensible enum types - Pull Request #62336 - JuliaLang/julia - GitHub](https://github.com/JuliaLang/julia/pull/62336) for an attempt at a first class mechanism to resolve this coordination problem.
