Why does this mixin fail to compile?
ryuukk_
ryuukk.dev at gmail.com
Mon Jul 1 09:39:35 UTC 2024
On Monday, 1 July 2024 at 09:29:50 UTC, Dennis wrote:
> On Monday, 1 July 2024 at 09:25:39 UTC, ryuukk_ wrote:
>> This simple mixin fails to compile, anyone know why?
>>
>> ```D
>> mixin implement;
>>
>> mixin template implement() {
>> mixin("struct _gen(T) {");
>> mixin("}");
>> }
>
> A string mixin must form a complete declaration / statement /
> expression / type, so you can't end on an open brace.
this is sad, how i am supposed to do a foreach inbetween?
```D
mixin implement!TEST;
mixin template implement(stuff) {
mixin("struct _gen(T) {");
// pseudo code
static foreach(args)
mixin("stuff");
mixin("}");
}
void main(){}
```
More information about the Digitalmars-d-learn
mailing list