Do string mixins work under -betterC?

DLearner bmqazwsx123 at gmail.com
Wed Dec 17 21:44:40 UTC 2025


On Wednesday, 17 December 2025 at 14:29:21 UTC, Adam D. Ruppe 
wrote:
> On Tuesday, 16 December 2025 at 23:25:18 UTC, DLearner wrote:
>> 1. Any proposals to mark a function as CTFE only?
>
> In OpenD you can
>
> ```
> string genStuff(string val) {
>         if(__ctfe) {
>                 return val ~ ";";
>         } else {
>                 assert(0);
>         }
> }
> ```
>
> That is, wrap the whole function in `if(__ctfe) {}` and it 
> passes this test since the gc use is now provably only in ctfe.
>
> I don't know about the other dmd release but it might work 
> there too, worth trying it.

This idea worked with DMD64 D Compiler v2.111.0.

In particular, it worked even when the equivalent of 'genStuff()' 
was defined in a different module and imported into main.

Thanks!


More information about the Digitalmars-d-learn mailing list