www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - add translate into c source code function

reply d007 <d007 gmail.com> writes:
The zig lang, v lang is able to translate into C code.

Is there a plan to translate d source code into C code ?  (or 
maybe just betterC subset)
May 08 2023
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 5/8/2023 11:37 PM, d007 wrote:
 The zig lang, v lang is able to translate into C code.
 
 Is there a plan to translate d source code into C code ?  (or maybe just
betterC 
 subset)
There isn't a current plan to implement one. Translating into C comes with a lot of problems. For example, C doesn't specify the order of evaluation of terms in an expression, while D does.
May 09 2023
parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
I suspect c++ would be a better target instead.

We already have a bunch of capability for this with the C++ header 
generator.

It only need to support a subset of the language, just enough to 
bootstrap the compiler. This would be a massive boost in undoing any 
harm from self hosting wrt. getting a working compiler going on a given 
target.

Not to mention the potential to making gdc/ldc lives a bit easier.
May 09 2023
prev sibling parent reply Sergey <kornburn yandex.ru> writes:
On Tuesday, 9 May 2023 at 06:37:58 UTC, d007 wrote:
 The zig lang, v lang is able to translate into C code.
Zig could run from C, but not to C AFAIK. Nim does this thing.
May 09 2023
parent Sergey <kornburn yandex.ru> writes:
On Tuesday, 9 May 2023 at 07:41:07 UTC, Sergey wrote:
 On Tuesday, 9 May 2023 at 06:37:58 UTC, d007 wrote:
 The zig lang, v lang is able to translate into C code.
Zig could run from C, but not to C AFAIK. Nim does this thing.
And it seems Odin also choose this path: https://youtu.be/g1qF9LZOoFE https://github.com/graphitemaster/codin
May 10 2023