| |
![ryuukk_'s Gravatar profile Gravatar of ryuukk_](//www.gravatar.com/avatar/eaf269d04f458c95560997aea9d55ca0?d=identicon&s=32) | Posted by ryuukk_ in reply to drug007 | Permalink Reply |
|
ryuukk_ ![ryuukk_'s Gravatar profile Gravatar of ryuukk_](//www.gravatar.com/avatar/eaf269d04f458c95560997aea9d55ca0?d=identicon&s=80)
Posted in reply to drug007
| On Monday, 1 July 2024 at 10:20:25 UTC, drug007 wrote:
> On 01.07.2024 12:39, ryuukk_ wrote:
>> 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(){}
>> ```
>
> No problem, make a full string then mixin it.
Your "no problem" = lot of string concatenation therefore slower and memory hungry, i have no desire to do that
|