On 2013-06-08 01:21, Manu wrote:Can't we just say that a delegate declared as extern(C++) is a member function?
So from my dconf talk, I detailed a nasty hack to handle member function
pointers in D.
My approach is not portable, so I'd like to see an expression formalised
in D, so this sort of interaction with C++ is possible, and also it may
be useful in D code directly.
I'm thinking something like this... Keen to hear thoughts.
My approach was this:
void function(T _this, ...args...);
Explicit 'this' pointer; only works with ABI's that pass 'this' as the
first integer argument.
What I suggest is:
void function(T this, ...args...);
Note, I use keyword 'this' as the first argument. This is the key that
distinguishes the expression as a member-function pointer rather than a
typical function pointer. Calls through this function pointer would know
to use the method calling convention rather than the static function
calling convention.
For 'extern(C++) void function(T this)', that would be to use the C++
'thiscall' convention.
I think this makes good sense, because other than the choice of calling
convention, it really is just a 'function' in every other way.
Or do you want to use member functions without connecting to C++ as well?