Debug help - opDispatch - unknown member function

Brother Bill brotherbill at mail.com
Tue Sep 9 00:40:31 UTC 2025


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."

So I tried that.  But the compiler didn't like it.
How should I play the game of passing in an unknown member 
function name?

```
import std.stdio;

void main()
{
	CallLogger!C l;
	l.callA(1, 2);
	l.callB("ABC");
	l.callHome("foo", "bar");   // Fails here
}

struct C
{
	void callA(int i, int j)
	{
	}

	void callB(string s)
	{

	}
}

struct CallLogger(C)
{
	C content;
	void opDispatch(string name, T...)(T vals)
	{
		writeln("called ", name);
		mixin("content." ~ name)(vals);
	}
}

```

Console output:
```
c:\dev\D\D_templates_tutorial\toy1\source\app.d(8): Error: no 
property `callHome` for `l` of type `app.CallLogger!(C)`
     l.callHome("foo", "bar");
      ^
```


More information about the Digitalmars-d-learn mailing list