Method pointers are *function* pointers?? Or delegates??

Mehrdad wfunction at hotmail.com
Fri May 18 12:17:28 PDT 2012


On Friday, 18 May 2012 at 18:59:23 UTC, Steven Schveighoffer 
wrote:
> On Fri, 18 May 2012 14:30:46 -0400, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> On 5/18/12 1:22 PM, Mehrdad wrote:
>>> My brain just exploded.
>>> Can someone explain what's going on?
>>>
>>> class Test
>>> {
>>> public void foo() { }
>>> }
>>>
>>> static assert(is(typeof(&Test.foo) == void function()));
>>
>> Looks like a bug. The assert should pass only if foo were 
>> static.
>
> No, this is not a bug.
>
> The purpose is so you can get the function pointer portion of a 
> delegate without an instance of the object.

I actually realized that might be the reason before I reported 
this, but then I thought:

In that case, shouldn't the 'this' parameter be explicitly part 
of the function (at the end of the parameter list)?


More information about the Digitalmars-d mailing list