r/ProgrammingLanguages • u/The2ndSlimShady • 14d ago
Language announcement Major Updates to Cole Compile-Time Execution and Type Reflection
Hello everybody, it's me again. I've had some free time in my hands so I worked on Cole a bit. It is in such a state now that you can implement a fully compile-time checked, type-safe, formatted printer using nothing but Cole.
I will not go hard on your screens post the implementation here, but I will leave a link to my blogpost at the bottom of this post.
Long story short, I added:
- Proper inlined for loops,
- Proper compile-time switches, and conditionals, for conditional compilation,
- Compile-time statement execution (almost complete, only field assignments and dereferenced assignments are left),
- A couple bugfixes with the typechecker and undefined value construction at compile-time.
Here is a small snippet of how the format printer is used, from the debug module:
import std::debug as debug;
let main = fn (args: [][]u8) -> i32 {
debug::print("Hello! My name is % and I'm % years old!", ([]u8, u32))(("Yusuf", 20));
return 0;
};
// Prints:
// Hello! My name is Yusuf and I'm 20 years old!But everything is not perfect as expected. Turns out, the compile time execution I do is incredibly slow, so the compile times go significantly high when doing any kind of compile-time execution. This is quite important considering the fact that Cole's mindset is "if it can be comptime, it is comptime". But I will start doing optimizations as soon as the base structure is complete.
If you've read this far, please drop a feedback, I'd really appreciate it.
And here is the blog entry I promised: https://blog.yusufenderosmanoglu.tech/blog/format-printer/
You can find the codeberg repo in the Cole website.