Hi guys! I'm working on kind of alternative C++. Namely I developed alternative modularity for C++.
YouTube demo:
About project
Main idea is to extend existing namespaces (instead of inventing alternative namespace concept, like in C++20 modules).
Another idea is to combine file system scope and module path, just like in Python, and very similar to Java.
There is a well detailed Readme.md, so you can learn details there.
Currently I have implemented the compiler (customized clang + own meta driver). I have covered it with tests, and even tried some small apps with STL, and it works! I have tested it on Linux and on Mac OS.
I understand that it's kind of crazy to go against mainstream, I also understand, that even though I have tried to do my best and complete compiler itself, it is still merely a toy, just a pet project.
And yet sometimes I can't stand and return to it again and again.
Surprisingly, I found that indeed, it's easy to implement some small projects with my extension.
Why and how it was started?
When you develop on C++ it's always about some bicycle invention, we create some harness, some sort of dynamic cast and so on.
One day it struck me: dude, you have some experience in compiler development, why can't you bring all that "harness" into compiler AST level? Why not to make own syntax extension?
That was started for fun, and for fun it is. Though, there were periods, when I was working full time, full of ambitions! So I started to love that thing after all, haha!
Perhaps some of you guys would be interested to review or contribute, may be just for fun ;-)
Feel free to ask questions!
P.S.: Now it's good to create plugins for popular IDEs (CLion, Eclispe, etc). So this is my next step.
Github:
[toc]
C++ Levitation Units
This is an extension to C++17, and it introduces original modularity support for C++.
Basic concepts
Levitation Packages is a replacement for C/C++ #include
directives
In C++ Levitation mode the latter is still supported, but only as landing pad for legacy C++ code.
Simplest things
Example 1
Let's consider simple example program with one package and two classes.
Defining units
MyPackage/UnitA.cppl
class A {
public:
static void sayHello() {
// send hello messge here
}
};
It looks pretty much like a regular C++ class. But instead it is
defined as a Levitation Unit
Implicitly this class is sorrounded by a namespace MyPackage::UnitA
.
To demonstrate that, let's take look at another class which uses the first one.
MyPackage/UnitB.cppl
#import MyPackage::UnitA
class B {
public:
static void useA() {
MyPackage::UnitA::A::sayHello();
}
};
Here we import MyPackage::UnitA
and, it allows to use itsβ¦
Thanks!
Top comments (2)
Cool! How do you make your own syntax extension?
Hey! Sorry for late response. I used LLVM technology to write extension, I've just updated clang and added own meta-driver. Here is a full list of changes
Again, sorry for late answer after several months of silence I just didn't expect any comments.