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

deadalnix deadalnix at gmail.com
Sat May 19 11:36:25 PDT 2012


Le 19/05/2012 03:37, Daniel Murphy a écrit :
> "Mehrdad"<wfunction at hotmail.com>  wrote in message
> news:ifswigmcenyryxzyvbpv at forum.dlang.org...
>> 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)?
>
> No, that won't work in all cases due to the ordering of parameters, 'this'
> and the hidden struct pointer.
>
>

extern(this) and you are done expressing thiscall.


More information about the Digitalmars-d mailing list