<div dir="ltr">On 10 June 2013 18:04, 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 09:23, Manu wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
That seems pretty awkward to me. Basically a hack.<br>
A function pointer is not a delegate, so I don't see why that should be<br>
used to describe one.<br>
</blockquote>
<br></div>
It depends on how you look at it. In D a delegate is a function pointer with a context pointer. In C++ a pointer to a member function is basically the same, the context pointer is just passed separately.</blockquote><div>
<br></div><div style>A function pointer is a pointer. A delegate is a pointer to a function and a context pointer, ie, 2 pointers.</div><div style>A pointer to a method is just a pointer to a function, but it's a special function which receives a 'this' argument with a special calling convention.</div>
<div style>It's definitely useful to be able to express a 'thiscall' function pointer.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, extern(C++) delegates are useful too in their own right<br>
</blockquote>
<br></div>
To do what? As far as I know C++ doesn't have anything corresponding to a D delegate.</blockquote><div><br></div><div style>C++ has FastDelegate, which I use to interact with D delegates all the time! ;)</div><div style>
extern(C++) delegate is required to specify the appropriate calling convention, otherwise it's just a delegate like usual.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I haven't needed to yet... but that doesn't mean it might not be useful.<br>
It would probably be used in D for tight binding with other systems.<br>
AngelScript binds to native code with member function pointers... just<br>
off the top of my head.<br>
</blockquote>
<br></div>
Actually I don't see why you can't use a delegate for this. The only difference is that it won't be virtual.</blockquote><div><br></div><div style>I'm just trying to show that sometimes you don't want a delegate, you just want a function pointer.</div>
<div style>delegate's contain the function pointer I'm after, so I can access it indirectly, but it's just not so useful. It's not typed (is void*), and you can't call through it.</div></div></div></div>