Thread overview | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 24, 2019 Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
I've been talking about this for years, and logged this a while back: https://issues.dlang.org/show_bug.cgi?id=19579 Is there anyone interested in or knows how to do this? It would really be super valuable; this idea would motivate inter-language projects that typically go C++-fist-with-a-D-binding to work the other way. Creating a pressure to write D-code first because the binding part is maintained automatically when you compile is potentially significant; gets programmers thinking and writing D code as first-class. Idea would be same as emitting .di files, but in this case only extern(C)/extern(C++) declarations would be emit to a .h file. I could use this to create some nice demos in my office which I think would get a few people talking and excited. |
February 24, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On 2/24/19 6:24 PM, Manu wrote:
> I've been talking about this for years, and logged this a while back:
> https://issues.dlang.org/show_bug.cgi?id=19579
>
> Is there anyone interested in or knows how to do this?
> It would really be super valuable; this idea would motivate
> inter-language projects that typically go C++-fist-with-a-D-binding to
> work the other way.
>
> Creating a pressure to write D-code first because the binding part is
> maintained automatically when you compile is potentially significant;
> gets programmers thinking and writing D code as first-class.
>
> Idea would be same as emitting .di files, but in this case only
> extern(C)/extern(C++) declarations would be emit to a .h file.
>
> I could use this to create some nice demos in my office which I think
> would get a few people talking and excited.
Yes that would be fantastic, and something I'd advocated for a long time as well. It would be in fact a prime application of the relatively recent ability to use dmd as a library. No need to modify the compiler, just walk the AST and output the header. Should be a couple hundred lines for good effect.
Andrei
|
February 25, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Sunday, 24 February 2019 at 23:24:53 UTC, Manu wrote:
> I've been talking about this for years, and logged this a while back: https://issues.dlang.org/show_bug.cgi?id=19579
>
> Is there anyone interested in or knows how to do this?
> It would really be super valuable; this idea would motivate
> inter-language projects that typically go C++-fist-with-a-D-binding to
> work the other way.
>
> Creating a pressure to write D-code first because the binding part is maintained automatically when you compile is potentially significant; gets programmers thinking and writing D code as first-class.
>
> Idea would be same as emitting .di files, but in this case only
> extern(C)/extern(C++) declarations would be emit to a .h file.
>
> I could use this to create some nice demos in my office which I think would get a few people talking and excited.
That sounds like a cool project and it's something I'm a bit used to working with, I just need to get familiar with DMD's source and I can start working on that.
|
February 25, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicolas D | On Monday, 25 February 2019 at 00:09:48 UTC, Nicolas D wrote: > That sounds like a cool project and it's something I'm a bit used to working with, I just need to get familiar with DMD's source and I can start working on that. Have a look at this PR for a head-start on C++ header generation with DMD: https://github.com/dlang/dmd/pull/8591 There's also Mihails's dtoh (for C bindings): https://gitlab.com/mihails.strasuns/dtoh |
February 24, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Sun, Feb 24, 2019 at 4:05 PM Andrei Alexandrescu via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
>
> On 2/24/19 6:24 PM, Manu wrote:
> > I've been talking about this for years, and logged this a while back: https://issues.dlang.org/show_bug.cgi?id=19579
> >
> > Is there anyone interested in or knows how to do this?
> > It would really be super valuable; this idea would motivate
> > inter-language projects that typically go C++-fist-with-a-D-binding to
> > work the other way.
> >
> > Creating a pressure to write D-code first because the binding part is maintained automatically when you compile is potentially significant; gets programmers thinking and writing D code as first-class.
> >
> > Idea would be same as emitting .di files, but in this case only
> > extern(C)/extern(C++) declarations would be emit to a .h file.
> >
> > I could use this to create some nice demos in my office which I think would get a few people talking and excited.
>
> Yes that would be fantastic, and something I'd advocated for a long time as well. It would be in fact a prime application of the relatively recent ability to use dmd as a library. No need to modify the compiler, just walk the AST and output the header. Should be a couple hundred lines for good effect.
Why wouldn't you do it in the same pass as the .di output?
|
February 25, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Seb | On 2019-02-25 02:00, Seb wrote: > Have a look at this PR for a head-start on C++ header generation with DMD: > > https://github.com/dlang/dmd/pull/8591 > > There's also Mihails's dtoh (for C bindings): > > https://gitlab.com/mihails.strasuns/dtoh And: https://github.com/thewilsonator/dtoh -- /Jacob Carlborg |
February 25, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On 2019-02-25 02:04, Manu wrote: > Why wouldn't you do it in the same pass as the .di output? * Separation of concerns * Simplifying the compiler ("simplifying" is not the correct description, rather avoid making the compiler more complex) I think the .di generation should be a separate tool as well. -- /Jacob Carlborg |
February 25, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Monday, 25 February 2019 at 10:20:34 UTC, Jacob Carlborg wrote:
> On 2019-02-25 02:04, Manu wrote:
>
>> Why wouldn't you do it in the same pass as the .di output?
>
> * Separation of concerns
> * Simplifying the compiler ("simplifying" is not the correct description, rather avoid making the compiler more complex)
>
> I think the .di generation should be a separate tool as well.
I don't think so.
h and .di generation have to be in sync with the AST.
The easiest way to guarantee that it is is by having it in the compiler test-suite.
Therefore it should be part of the main compiler.
Also it removes the need of having to add another application to your build.
|
February 25, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Monday, 25 February 2019 at 10:20:34 UTC, Jacob Carlborg wrote:
> On 2019-02-25 02:04, Manu wrote:
>
>> Why wouldn't you do it in the same pass as the .di output?
>
> * Separation of concerns
> * Simplifying the compiler ("simplifying" is not the correct description, rather avoid making the compiler more complex)
>
> I think the .di generation should be a separate tool as well.
+1
Also: is there anyone else that need this? Because it could well be a fringe need (like .di generation)
|
February 25, 2019 Re: Make DMD emit C++ .h files same as .di files | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Sunday, 24 February 2019 at 23:24:53 UTC, Manu wrote:
> I've been talking about this for years, and logged this a while back: https://issues.dlang.org/show_bug.cgi?id=19579
>
> Is there anyone interested in or knows how to do this?
> It would really be super valuable; this idea would motivate
> inter-language projects that typically go C++-fist-with-a-D-binding to
> work the other way.
+1
|
Copyright © 1999-2021 by the D Language Foundation