On Tuesday, 9 September 2025 at 11:57:54 UTC, Brother Bill wrote:
On Tuesday, 9 September 2025 at 01:24:59 UTC, monkyyy wrote:

```
// I suggest a habit of avoiding simple names when generating mixin code
```

Please provide an example where providing simple names causes 'trouble'.

```d
import std;
struct Vector(int N,T,string fields){
        static foreach(I;0..N){
                mixin("T "~fields[I]~";");
        }
auto opDispatch(string s)(){//I suggest a habit of avoiding simple names when generating mixin code
                return mixin((){
                        string output="tuple(";
                        foreach(C;s){
                                output~=C;
                                output~=',';
                        }
                        output~=")";
                        return output;
                }());
        }
}
unittest{
        Vector!(4,int,"xyzs") foo;
        foo.x=5;
        foo.y=3;
        foo.s=7;
        assert(foo.sx==tuple(7,5));
}
```

Reply via email to