Class methods in D?

Jacob Carlborg doob at me.com
Fri May 4 14:21:57 PDT 2012


On 2012-05-04 22:46, Steven Schveighoffer wrote:
> On Fri, 04 May 2012 15:53:36 -0400, Jacob Carlborg <doob at me.com> wrote:
>
>> On 2012-05-04 16:31, Mehrdad wrote:
>>> Oooooh okay, I see. Let me try it. :)
>>>
>>> @Everyone: Haha thanks for pointing me to the existing libraries. :) I'm
>>> doing this more for learning than anything else, so I'm trying to solve
>>> these problems myself instead of just using another library.
>>>
>>> And it seems to be going well:
>>>
>>> class Window
>>> {
>>> private static shared tstring classNames[TypeInfo];
>>>
>>> shared static this() { EnableVisualStyles();
>>> RegisterClass(typeid(typeof(this))); }
>>
>> For classes there's a shourtcut:
>>
>> this.classinfo;
>
> Not really. this gets the TypeInfo of the *runtime* type (and BTW,
> classinfo is deprecated IIRC, use typeid(this) instead). The code
> Mehrdad wrote above gets the TypeInfo of the *static* type. Not to
> mention, there's no 'this' in a static constructor.
>
> -Steve

Ah, didn't think that far. BTW, why is .classinfo deprecated?

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list