Mixin C

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Mar 8 04:12:01 UTC 2024


On 08/03/2024 5:02 PM, Paul Backus wrote:
> On Friday, 8 March 2024 at 03:37:02 UTC, Richard (Rikki) Andrew 
> Cattermole wrote:
>> Having raw C blocks in a D file gives me concern for IDE's wrt. syntax 
>> highlighting.
>>
>> We do have a comparable feature with inline assembly support in 
>> ldc/gdc where it uses strings.
>>
>> I would suggest that this is the direction to go in rather than a raw 
>> code block.
> 
> Yeah that's reasonable. Honestly it would barely even look different if 
> you use a q{...} string:
> 
>      mixin(C) q{
>          #include <stdio.h>
>          printf("Hello from C!\n");
>      };
> 
> I guess the lexer currently barfs on #include, but surely we can bend 
> the rules on that if we need to.

I was thinking about a new kind of string, one that produces a struct 
that has both a language string that the user provided as well as the 
contents.

That way editors can syntax highlight if they understand it, or ignore 
it if they don't.

Might be overkill, but it does have some interesting possibilities.


More information about the dip.ideas mailing list