On 2013-06-10 14:32, Michel Fortin wrote:Then he's asking for (more) type safe delegates and support for C++ member function pointers.
Type-safety. I mean, you can do this if you want:
auto funcptr = &Object.toString;
auto object = new Object;
// now call our function using object
string delegate() deleg;
deleg.ptr = cast(void*)object;
deleg.funcptr = funcptr;
but this is not type-safe: the funcptr type ("string function()") is
actually wrong (it'll only work if called from a delegate) and the
object pointer the in the delegate is a void*. All Manu is asking is
that funcptr is of a correct type so you can call it directly by
supplying "this" as an argument, like this:
funcptr(object);
The problem is that this "correct type" for the function pointer does
not exist currently. Calling a member function uses a different ABI, so
the type needs to know somehow its a pointer to a member function (and
that its first parameter is "this"), otherwise the generated code at the
call site will be all wrong.