<div dir="ltr">On 10 June 2013 16:50, 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-08 01:21, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So from my dconf talk, I detailed a nasty hack to handle member function<br>
pointers in D.<br>
My approach is not portable, so I'd like to see an expression formalised<br>
in D, so this sort of interaction with C++ is possible, and also it may<br>
be useful in D code directly.<br>
<br>
I'm thinking something like this... Keen to hear thoughts.<br>
<br>
My approach was this:<br>
void function(T _this, ...args...);<br>
<br>
Explicit 'this' pointer; only works with ABI's that pass 'this' as the<br>
first integer argument.<br>
<br>
What I suggest is:<br>
void function(T this, ...args...);<br>
<br>
Note, I use keyword 'this' as the first argument. This is the key that<br>
distinguishes the expression as a member-function pointer rather than a<br>
typical function pointer. Calls through this function pointer would know<br>
to use the method calling convention rather than the static function<br>
calling convention.<br>
<br>
For 'extern(C++) void function(T this)', that would be to use the C++<br>
'thiscall' convention.<br>
<br>
I think this makes good sense, because other than the choice of calling<br>
convention, it really is just a 'function' in every other way.<br>
</blockquote>
<br></div>
Can't we just say that a delegate declared as extern(C++) is a member function?</blockquote><div><br></div><div style>That seems pretty awkward to me. Basically a hack.</div><div style>A function pointer is not a delegate, so I don't see why that should be used to describe one.</div>
<div style>Also, extern(C++) delegates are useful too in their own right</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Or do you want to use member functions without connecting to C++ as well?</blockquote>
<div><br></div><div style>I haven't needed to yet... but that doesn't mean it might not be useful.</div><div style>It would probably be used in D for tight binding with other systems. AngelScript binds to native code with member function pointers... just off the top of my head.<br>
</div></div></div></div>