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

Alex Rønne Petersen alex at lycus.org
Fri May 18 12:37:40 PDT 2012


On 18-05-2012 21:34, Steven Schveighoffer wrote:
> On Fri, 18 May 2012 15:17:28 -0400, Mehrdad <wfunction at hotmail.com> wrote:
>
>> 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)?
>
> That would be nice, wouldn't it? :)
>
> -Steve

At least it would prevent writing platform/compiler-specific code...

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list