Show HN: The C³ Programming Language version 2

2 9o1d 1 7/6/2025, 11:09:32 AM
I'm making a second version for the new C³ programming language.

Added modifiers. These are modules that add additional functionality to the main module.

I can give you an example of another implementation of a string for C in the chars folder. In the first version, there were many variable fields in the chars structure. This turns out to make the module's functions complex. Then I remembered the basic principle of the new programming language C³ is maximum simplicity. So I left only one field in the chars structure, which is a pointer to char. In this way, the structure can be directly converted to a char pointer. The structure has functions to support working with arrays.

You may wonder where the other fields are, such as buffer size and write and read positions? I decided to make them in the form of separate structures, iter, and iter_read. These are modificators. They are added as header files and add functions. You can use many iterators for a single chars structure.

These three structures are combined in a common char_array control structure, which is responsible for automatic control of pointers. It has one pointer each to chars, iter, iter_read.

Iterator modules are modifiers. They add independent fields to the main structure, and additional functions for working with them. Thus, they adopt the prefix of the main structure. The names are chars, chars_iter for writing, chars_iter_read for reading. For now, nesting is one. I plan to increase the number of modifiers.

I'm currently making a parser for the C programming language, and this architecture allows you to use a lot of reading iterators. Thus, part of the structure is passed by reference and by value.

When I pass some structs by the value of *p, then inside the function I get my own instance of the struct that I can modify. For example, for parsing. And if successful, I can apply the changes to the original structure.

In this project, I'm interested in new architectural possibilities, so I can change structures frequently for improvements.

https://gitlab.com/9o1d/c3v2

Version 1 is available at https://azhibaev.com/c3.zip

Stay tuned !

Comments (1)

stefanos82 · 9h ago
I hope you do know there's a C3 language for a number of years already https://github.com/c3lang/c3c/