ImportC shows the way to D3?
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Mon Jun 20 08:46:25 UTC 2022
On Monday, 20 June 2022 at 08:05:38 UTC, claptrap wrote:
> So if D can "import" C code then could the same mechanism be
> used to move to D3? Have the compiler compile D2 and D3 code to
> the same AST?
>
> Disclaimer : I dont know exactly how ImportC works but it
> sounds like it compiles C code into the same AST that D code
> uses. Then its all compiled the same.
>
> yeah I know D3... but it could be a way to introduce breaking
> changes without too much pain?
>
> Surely i cant be the only person who's thought of this?
Compiling to the same AST does not allow you to change semantics
without ending up with more complex compiler internals. So you
are limited to smaller semantic adjustments and syntax.
I've suggested somewhere else that if DMD implemented a high
level IR between frontend and backend then you could compile D2
and D3 to the same high level IR.
But you still have to replicate templates in both your D2 and D3
code bases as you don't want to do D-style meta programming in
the high level IR that sits before the backend. You also cannot
just combine D3 with D2 templates when D2 is capable of
introspection.
If fixing bugs and completing the semantics of D2 is time
consuming, why would you make it even more difficult to achieve
by merging D3 into the D2 frontend? Yes, this also applies to
"import C". It was done at the wrong time. The internals should
have been redesigned first to handle it gracefully.
More information about the Digitalmars-d
mailing list