Do string mixins work under -betterC?

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Wed Dec 17 00:13:42 UTC 2025


On 17/12/2025 12:25 PM, DLearner wrote:
> On Tuesday, 16 December 2025 at 20:56:06 UTC, Richard (Rikki) Andrew 
> Cattermole wrote:
>> 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.
>>>
> [...]
> 
>> 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.
> 
> 1. Any proposals to mark a function as CTFE only?

No, this is something that should've been done a while back.

The main concern is that you can get a linker error if you don't emit a 
function that was called.


More information about the Digitalmars-d-learn mailing list