Design of register_kinds! in JuliaSyntax.jl/src/julia/kinds.jl

“”"
register_kinds!(mod, module_id, names)

Register custom Kinds 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?

If you see julia/JuliaSyntax/src/julia/kinds.jl at a6567e17f63af24909edfe54cbf2a41c4165b308 · JuliaLang/julia · GitHub it describes a couple other modules which also register kinds. One is JuliaLowering, julia/JuliaLowering at a6567e17f63af24909edfe54cbf2a41c4165b308 · JuliaLang/julia · GitHub and one is JuliaSyntaxFormatter, GitHub - c42f/JuliaSyntaxFormatter.jl: Semantic highlighting of JuliaSyntax ASTs as Julia code · GitHub