<div dir="ltr">On 10 June 2013 22:56, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 2013-06-10 14:32, Michel Fortin wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Type-safety. I mean, you can do this if you want:<br>
<br>
     auto funcptr = &Object.toString;<br>
     auto object = new Object;<br>
<br>
     // now call our function using object<br>
     string delegate() deleg;<br>
     deleg.ptr = cast(void*)object;<br>
     deleg.funcptr = funcptr;<br>
<br>
but this is not type-safe: the funcptr type ("string function()") is<br>
actually wrong (it'll only work if called from a delegate) and the<br>
object pointer the in the delegate is a void*. All Manu is asking is<br>
that funcptr is of a correct type so you can call it directly by<br>
supplying "this" as an argument, like this:<br>
<br>
     funcptr(object);<br>
<br>
The problem is that this "correct type" for the function pointer does<br>
not exist currently. Calling a member function uses a different ABI, so<br>
the type needs to know somehow its a pointer to a member function (and<br>
that its first parameter is "this"), otherwise the generated code at the<br>
call site will be all wrong.<br>
</blockquote>
<br></div>
Then he's asking for (more) type safe delegates and support for C++ member function pointers.</blockquote><div><br></div><div style>I'm really not asking for delegates (although they could become more typesafe given my suggestion), just a member function pointer. And not C++ style as you say, my suggestion is much simpler than that, and would fit nicely in D.</div>
</div></div></div>