Add ImportC compiler to dmd
IGotD-
nise at nise.com
Tue May 11 16:57:15 UTC 2021
On Sunday, 9 May 2021 at 20:57:06 UTC, Walter Bright wrote:
> https://github.com/dlang/dmd/pull/12507
>
> If you could add a C compiler to dmd with 3000 lines of code,
> so C code could be imported directly? I would!
I'd say no to this.
Why?
Adding a C compiler into the D compiler will increase the
maintenance work load and open up for new interesting bugs. This
is the last D needs. Also there are several areas where D needs
to improve (memory management) and add this split personally is a
distraction.
I also find this a bit strange coming from a person that thinks
making GC pointers an own type would increase the complexity of
the compiler, then suddenly wants to add a complete C compiler
into the D compiler.
Also the question raises what will be supported and what will
not. There are a lot of header files out there that are a mix
between C and C++. Adding importing C++ is difficult and the
scope what is supported must be limited. This means that a lot of
header files will not work directly. C++11 and beyond with
templates, just forget it.
I understand that importC would greatly make FFI easier but I
think this is easier said than done. It is definitely not worth
making the D compiler into a Frankensteins monster. I would go
the conversion tool (that converts C header files to D files)
route in order to decouple a foreign language to the D language.
More information about the Digitalmars-d
mailing list