Why can't we transpile C++ to D?

sighoya sighoya at gmail.com
Thu Jun 10 19:02:21 UTC 2021


On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote:
> Sorry, I'm rather ignorant when it comes to this, but why can't 
> we use [pegged](https://github.com/PhilippeSigaud/Pegged) to 
> transpile C++ code to D?

See 
https://stackoverflow.com/questions/14589346/is-c-context-free-or-context-sensitive#answer-14589567

Mixing semantic with parsing isn't necessarily a good idea.

> Then we won't need a nogc compatible std library and so many 
> other things could get easier, like getting legacy code to use 
> Dlang.

That doesn't solve the ABI compatibility to C++, only if source 
is available, but they may be compiled with compilers which can't 
build anymore with the current tool chain at least without to 
rebuild the tool chain.

> It might not be worth it for C+17 and beyond, but older 
> codebases could benefit significantly, right?

The problem is that old looking code doesn't become modern when 
it is transpired to D as the concepts to do things have changed.


More information about the Digitalmars-d-learn mailing list