Chomik: Complex Type Names

I was born in 1973, in Cracow, Poland. I am a software engineer.
In Chomik 0.2.2 I introduced a feature that significantly improves the way libraries can be written and reused: complex type names. 🎯
This change may look small at first glance, but in practice it enables something that was previously difficult to achieve in Chomik—true namespace flexibility controlled by the library user.
Let’s look at the motivation and how the feature works.
The Problem with Simple Type Names
Until now, type names in Chomik were typically single identifiers. That worked well for small programs, but it created a problem for libraries.
When a library defines types like:type widget_class = { window, button, icon };type widget_mode = { normal, resizing, moving };
those names become part of the user's namespace. If two libraries define similar types—or if the same library needs to be included multiple times—name collisions become inevitable.
Many languages solve this with namespaces or modules. Chomik, however, follows a different philosophy: namespaces should be programmable and dynamic, just like the rest of the language.
Complex Type Names
Starting with Chomik 0.2.2, type names can now be built using the syntax:
complex [ item1 item2 item3 ]
This allows type names to be composed dynamically from multiple identifiers. Also evaluating variables and using literals is allowed, like in a regular Chomik name.
For example, in the SDL widget library I recently updated, you can see definitions like:type complex [<sdl chomik widgets prefix> widget_class] = { window, button, icon, text, menu bar, drop down menu };type complex [<sdl chomik widgets prefix> widget_mode] = { normal, resizing, moving };
Here, the type name is not fixed. It depends on the value of:<sdl chomik widgets prefix>
This means the library does not dictate where its symbols appear in the user's namespace.
Instead, the client program decides.
True Code Reusability
Because the prefix is controlled by the user, the same library can be included multiple times with different namespaces.
For example:let sdl chomik widgets prefix=value integer 0;include "sdl_chomik_widgets.sdl_chomik"let sdl chomik widgets prefix=value integer 1;include "sdl_chomik_widgets.sdl_chomik"
Now the program effectively has two independent instances of the library.
This works because all types and variables inside the library depend on the prefix.
Even better, the prefix does not need to be an integer. It can be:
an identifier
an integer
an enum value
or any other value usable in names
This means the library user has complete freedom to decide how the imported symbols are organized.
In practice, this finally enables something very important:
✅ Real code reuse in Chomik libraries
Example from the SDL Widgets Library
In the current version of sdl_chomik_widgets, types are defined like this:type complex [<sdl chomik widgets prefix> left_or_right] = { left, center, right };type complex [<sdl chomik widgets prefix> up_or_down] = { up, up bar, center, down };
The library also uses the prefix in its variables:let <sdl chomik widgets prefix> the amount of widgets = value integer 0;
Because of this design, the same widget system can exist multiple times inside the same program without conflicts.
For example:
multiple UI contexts
separate GUI systems for different modules
experimental widget sets
All without modifying the library itself. 🚀
The New range Keyword
Alongside complex type names, version 0.2.2 also introduces the optional keyword:range
used before integer ranges.
Previously, Chomik assumed that if a type name was expected and it was not a single identifier, then it must be a range. While convenient, that assumption was a bit too strong.
Now ranges can be written explicitly:
range 0..100
The keyword is optional, so existing code continues to work.
However, it is recommended, especially in libraries, because it makes the code clearer and avoids ambiguities as the language evolves.
Recommended Style Going Forward
With these changes, a good style for library code is:
Prefer complex type names rather than single identifiers
Use prefix values controlled by the client
Use the
rangekeyword for integer ranges
This makes libraries:
safer
easier to reuse
easier to integrate into larger systems
Final Thoughts
Complex type names might look like a small syntactic addition, but they align perfectly with the core philosophy of Chomik:
Names are values, and values can build other names.
By extending that idea to types, Chomik gains a powerful mechanism for library composition and namespace control, without introducing traditional modules or namespaces.
The result is a system where the user—not the library—decides how code fits into their program.
And that, in my opinion, is the most flexible form of reuse. 🐹
More about Chomik:
https://www.chomik.tech
https://www.perkun.org/




