<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 10, 2013 at 10:13 PM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On 2013-06-10 18:34, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On 11 June 2013 02:26, Jacob Carlborg <<a href="mailto:doob@me.com" target="_blank">doob@me.com</a> <mailto:<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>>><div><div><br>
wrote:<br>
<br>
    On 2013-06-10 17:40, David Nadlinger wrote:<br>
<br>
        Let me try to summarize it in code:<br>
<br>
        ---<br>
        class A { void foo(); }<br>
        auto memberFun = (&A.foo).funcptr;<br>
<br>
        auto a = new A;<br>
        memberFun(a);<br>
        ---<br>
<br>
<br>
    Why is this better than a delegate?<br>
<br>
<br></div></div><div>
It's not 'better', it's different.<br>
</div></blockquote>
<br><div>
class A { void foo(); }<br>
auto memberFun = (&A.foo).funcptr;<br>
<br>
auto a = new A;<br></div>
void delegate () dg;<br>
dg.funcptr = memberFun;<br>
dg.ptr = cast(void*) a;<br>
dg();<br>
<br>
The details can be hidden in a function call. Sure, a delegate could be type safe but still don't see the point.<span><font color="#888888"><br>
<br>
-- <br>
/Jacob Carlborg<br></font></span></blockquote><div><br></div><div>Greetings</div><div><br></div><div>Apologies for bringing up this year old thread.</div><div><br></div><div>With <a href="https://github.com/D-Programming-Language/dmd/pull/3181" target="_blank">https://github.com/D-Programming-Language/dmd/pull/3181</a> getting merged, it is no longer feasible to directly assign dg.funcptr (which is not an lvalue now). The problem is that the code suggested by David also does not work.</div>


<div><br></div><div>Is there an alternative?</div><div><br></div><div>Regards</div><div>- Puneet</div></div><br></div></div>