Member function pointers

Manu turkeyman at gmail.com
Mon Jun 10 09:44:14 PDT 2013


On 11 June 2013 02:28, Jacob Carlborg <doob at me.com> wrote:

> On 2013-06-10 17:36, Manu wrote:
>
>  My suggestion is: void function(T this) funcptr;
>> This is a function pointer (not a delegate), but using keyword 'this'
>> gives the critical detail to the compiler that it's a member function
>> pointer, and to use the appropriate calling convention when making calls
>> through this pointer.
>> UFCS makes it awesome.
>>
>
> What I don't understand is what this give you that a delegate doesn't. You
> need the "this" pointer to call the function pointer anyway. With a
> delegate it's bundled.


It's just a pointer, 'this' is associated at the call site. And it's
strongly typed.
If you don't want a bundle, why be forced to use a bundled type?

Consider this, why would you ever want an int* when you can have an int[]?
We could remove the syntax for int*, and make it only accessible via
int[].ptr... and make: is(typeof(int[].ptr) == size_t)? :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130611/aa7c5dc1/attachment.html>


More information about the Digitalmars-d mailing list