D is our last hope

Walter Bright newshound2 at digitalmars.com
Sun Dec 24 06:21:46 UTC 2023


On 12/23/2023 5:11 AM, Araq wrote:
> There is also nothing "simple" about implementing C11 anyway with its "sequence 
> points" and memory model and atomics and "volatile" and its undefined behaviors.

It is simple if the optimizer is not doing certain kinds of optimizations on 
multithreaded code. These features also have nothing to do with turning C code 
into an AST and translating it.

The dmd backend was originally built for C, and so already had C semantics like 
volatile wired in. gdc and ldc also take advantage of mature C code generators.

All I really needed to implement was a C parser and then adapt the resulting AST 
to D. I didn't even need to implement the C preprocessor (phew!).

Rikki has recently contributed an implementation of stdatomic for us.

> But hey, it was simple in 1988 I guess when Mr Bright found his love for C...

Multiple CPUs on one chip weren't a thing then.

P.S. sequence points are also a thing in D. ImportC doesn't make it any better 
or worse, it's the same thing.



More information about the Digitalmars-d mailing list