My idea for seamless interop to C++
Wed Nov 18 23:32:00 UTC 2020
On Wednesday, 18 November 2020 at 14:04:36 UTC, Markus wrote:
> Hi there!
> For months I've been thinking on how to escape C++.
> Here are my thoughts about that matter:
> What do think about that idea. Is it worth a shot? I'm thinking
> about implementing such a tool.
> Have fun,
Kudos for the detailed comparison between the different C++
That said, I'm sorry to disappoint, but I don't think this would
be a a viable approach (translating D source code to C++ (not
just headers) while preserving the high-level structure). D is
also a complex language (just the complexity is much less and
much better managed compared to C++) and doing a semantically
correct translation (while even preserving high-level concepts,
such as OOP) would be quite hard. D's template system is more
powerful (and more sane) than the one of C++, so you can't
translate any D code that use templates basically (which is
pretty much the whole standard and runtime library).
I believe there are 5 approaches / areas worth investing to:
1. dmd's built-in extern (C/C++) ABI and header generation 
  
2. dpp 
3. dstep  (I really wish Atilla would collaborate with Jacob
on merging dpp and dstep)
4. cling  - as far as I know Symmetry have build some sort of
bridge between D and C++ based on this.
5. Calypso - using Qt from D is nothing sort of astonishing!
Unfortunately all the work is done by single developer. If others
would join, hopefully the project could progress much faster.
: https://dlang.org/changelog/pending.html#dtoh-improvements |
I'm curious to know more on your thoughts on dmd's dtoh.
You can find some sample generated code here:
More information about the Digitalmars-d