On Tuesday, 9 September 2025 at 01:08:41 UTC, Brother Bill wrote:
On Tuesday, 9 September 2025 at 00:45:00 UTC, monkyyy wrote:
On Tuesday, 9 September 2025 at 00:40:31 UTC, Brother Bill wrote:
https://tour.dlang.org/tour/en/gems/opdispatch-opapply

This states: "Any unknown member function call to that type is passed to opDispatch, passing the unknown member function's name as a string template parameter."

[...]

you didnt define "callhome" so the the mixin fails, this propagates a "__error" or something, and opDispatch when it contains an error doesnt pass it up the stack

Then I'm not clear what an "unknown" member function name means.

Kindly provide an example.

```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!(3,int,"xyz") foo;
        foo.x=5;
        foo.y=3;
        foo.yx.writeln;
        Vector!(4,ubyte,"rgba") bar;
        bar.bgr.writeln;
}
```

Reply via email to