Member function pointers

Manu turkeyman at gmail.com
Fri Jun 7 20:47:41 PDT 2013


On 8 June 2013 12:29, Michel Fortin <michel.fortin at michelf.ca> wrote:

> On 2013-06-07 23:57:40 +0000, Manu <turkeyman at gmail.com> said:
>
>  Precisely. The concept is already embedded inside of delegate, but
>> delegate
>> is framed like a piece of magic, rather than a well defined compound of
>> more primitive pieces.
>>
>
> Delegates are not parametrized on the type of "this", which makes them
> easier to move around. I would not change delegates.
>

Actually, that's very true. Good point, and I think this is almost the key
distinction.

But function pointers with a "this" parameter would be useful. You can
> achieve this using a template struct containing a pointer and a call
> method: the call method would generate a local delegate variable from the
> pointer and and call it. What you can't do without compiler support is get
> such a pointer in a type-safe manner.


Yup, this is what I originally did. It's big and ugly, I didn't like it,
and deleted it. I think the syntax I suggest is simple and obvious, and
naturally, typesafe.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130608/81b7dd65/attachment-0001.html>


More information about the Digitalmars-d mailing list