4 ms·
One of my dream side-projects is to create something inspired by Ken Thompson's C (the plan9 compiler), with some ideas borrowed for Go, where this "almost C" l
by oscargrouch 7y ago
One of my dream side-projects is to create something inspired by Ken Thompson's C (the plan9 compiler), with some ideas borrowed for Go, where this "almost C" language could be written in a valid C just like you can do it with C++.
things like:
(Composing structs)
struct Parent {int number}
struct Child {Parent; int another_number} // anonymous struct convention
Child c;
c.number = 10;
c.another_number = 11;
(Object notation, namespacing)
int DoThis(Child* this, int input) {}
Child* c ...
c->DoThis(10)
(Someway to define public/private in structs and methods, like Go do with convention of Lowercase/Uppercase components/function names)
and Finally
(Someway to define a interface and use vtables when needed just like Go´s Interface but in a more C compatible way like.. )
struct MyInterface {
int (*Read)(int a, int b);
int (*Write)(int a, int b);
}
or
struct MyInterface {
int Read(int);
int Write(char);
}
struct X {}
int Read(X* this, int n) {}
int Write(X* this, char c) {}
X x = X{};
x.Read(10);
x.Write('b');
MyInterface* c = &x;
(...)
(templates) - C++ way is fine
Thats it. With all this you would have "a better C", with compability with C codebase and still a language much simpler than C++, yet powerful.