Thread overview
add translate into c source code function
May 09, 2023
d007
May 09, 2023
Walter Bright
May 09, 2023
Sergey
May 10, 2023
Sergey
May 09, 2023

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 09, 2023
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

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
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 10, 2023

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