January 16, 2022 Re: ImportC + metaprogramming? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 1/16/2022 8:36 AM, Steven Schveighoffer wrote: > Hm..., how does this help with preprocessor defines? Unfortunately, it doesn't. > // rewrite mylib #defines as enums here > Do you have a plan for this? Not at the moment. |
January 17, 2022 Re: ImportC + metaprogramming? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Sunday, 16 January 2022 at 08:13:37 UTC, Walter Bright wrote:
> In this PR,
>
> https://github.com/dlang/druntime/pull/3670
>
> I added the ability for an ImportC file to import a D file. The initial purpose was so that core.stdc.stdarg could be imported to support variadics in C, without reimplementing them.
>
> I realized that this actually works - ImportC code can call D code! even use D templates!
>
> So then I got to thinking "what the hell have I unleashed?"
>
> I think I just destroyed dtoh.
Unleashed the dragon
|
January 17, 2022 Re: ImportC + metaprogramming? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bauss | On Monday, 17 January 2022 at 07:11:08 UTC, bauss wrote:
> On Sunday, 16 January 2022 at 08:13:37 UTC, Walter Bright wrote:
>> In this PR,
>>
>> https://github.com/dlang/druntime/pull/3670
>>
>> I added the ability for an ImportC file to import a D file. The initial purpose was so that core.stdc.stdarg could be imported to support variadics in C, without reimplementing them.
>>
>> I realized that this actually works - ImportC code can call D code! even use D templates!
>>
>> So then I got to thinking "what the hell have I unleashed?"
>>
>> I think I just destroyed dtoh.
>
> Unleashed the dragon
The dragon has no flame. If you use this how do you use (say) a slice? dtoh does this automatically by providing a templates struct, what does this do on the C side?
|
January 17, 2022 Re: ImportC + metaprogramming? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | I can now verify that ImportC can import D files, and instantiate templates from those files! |
January 19, 2022 Re: ImportC + metaprogramming? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Thanks for this solution! I will try to use this code for my project. |
Copyright © 1999-2021 by the D Language Foundation