ZL: A C/C++ Compatible Language with Hygienic Macros
zl-lang.org
zl-lang.org
Because my language[1] just got the ability to directly include .h files and access to the functions and symbols therein. Small snippet[2]:
c_import {
@c_include("GLFW/glfw3.h");
@c_include("stdlib.h");
@c_include("stdio.h");
}
I realize this probably comes across as trying to one-up another person's work but I just got this working a few minutes ago and I'm really excited to demo it![1]: https://github.com/andrewrk/zig
[2]: https://github.com/andrewrk/tetris/blob/aaf09e30a3a7b9ed8f34...
OK I think I understand what the author means by "C/C++ compatible". Check out this snippet[3]
> Note that there is no #include line in the source file. The ZL prelude includes some of the more common functions from the C standard library and ZL source files are not run through the C preprocessor by default. The driver script zlc is meant to act as a drop drop in replacement for GCC. For example,
> zlc main.zl file1.cpp file2.zlp -o main
I think that zl compiles to C and also acts as a compiler driver.
I've tried to imagine it as some kind of preprocessor with C files as output.
Fow example this:
struct Test {
int testFunc(int a) { return a * a; }
...
};
int main() {
Test t;
return t.testFunc(2);
}
Can be transformed to C code: struct Test {
...
};
int Test_testFunc_int_int(Test * this, int a) {
return a * a;
}
int main() {
Test t;
return Test_testFunc_int_int(&t, 2);
}
Does anyone know language or meta-language (with output as C files) or some libs maybe similar to this?As dragonwriter said, C++ begun as a preprocessor. The cfront sources are available here:
http://www.softwarepreservation.org/projects/c_plus_plus/ind...
About your language, it's possible to do your own by parsing the AST output of GCC with "-fdump-translation-unit".
I think Uniform Call Syntax is planned for C++17 or maybe 20 (f(a,b)=a.f(b)).
"The current ZL prototype supports most of C and an important subset of C++"
Looks like they have complete C compatibility and proof-of-concept C++ compatibility but not complete.