Do string mixins work under -betterC?

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Tue Dec 16 20:56:06 UTC 2025


On 17/12/2025 9:48 AM, DLearner wrote:
> I have a rather complicated string mixin defined and invoked from within 
> the same source file.
> Which seems to work.
> 
> But when I move the mixin definition to a separate module, and import 
> that module into the original source file, the compilation collapses 
> complaining that array concatenation requires the GC, which is not 
> available with -betterC.
> 
> DLearner

Yes it does.

Are you trying to extract the string mixin argument out into a function?

```d
string genStuff(string val) {
	return val ~ ";";
}

void myFunc() {
	mixin(genStuff("this"));
}
```

This won't work without a way to mark `genStuff` as CTFE only. Which 
doesn't exist currently.

Compiler has to know that a given execution context is CTFE only 
otherwise disallowed.


More information about the Digitalmars-d-learn mailing list