View mode: basic / threaded / horizontal-split · Log in · Help
May 04, 2012
Re: Class methods in D?
On 2012-05-04 22:46, Steven Schveighoffer wrote:
> On Fri, 04 May 2012 15:53:36 -0400, Jacob Carlborg <doob@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
May 04, 2012
Re: Class methods in D?
On Fri, 04 May 2012 17:21:57 -0400, Jacob Carlborg <doob@me.com> wrote:

> On 2012-05-04 22:46, Steven Schveighoffer wrote:
>> On Fri, 04 May 2012 15:53:36 -0400, Jacob Carlborg <doob@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?

Because typeid(this) gives the same exact thing.  A long time ago, there  
was a separate Classinfo type.  But it has been merged into TypeInfo.

It was determined also that the most useful thing to return from typeid  
was the runtime TypeInfo, since you could always get the static typeinfo  
by doing typeid(typeof(x)).

TBH, I'm not exactly sure that classinfo is officially deprecated, but I  
don't think it appears anywhere in the docs.

-Steve
May 04, 2012
Re: Class methods in D?
On 2012-05-04 23:31, Steven Schveighoffer wrote:

> TBH, I'm not exactly sure that classinfo is officially deprecated, but I
> don't think it appears anywhere in the docs.

http://dlang.org/property.html#classinfo

-- 
/Jacob Carlborg
May 07, 2012
Re: Class methods in D?
On Fri, 04 May 2012 18:05:39 -0400, Jacob Carlborg <doob@me.com> wrote:

> On 2012-05-04 23:31, Steven Schveighoffer wrote:
>
>> TBH, I'm not exactly sure that classinfo is officially deprecated, but I
>> don't think it appears anywhere in the docs.
>
> http://dlang.org/property.html#classinfo

http://d.puremagic.com/issues/show_bug.cgi?id=8059

:)

I also found this statement from Walter while searching for pre-existing  
bugs:

http://forum.dlang.org/post/hffssv$9ro$1@digitalmars.com

-Steve
Next ›   Last »
1 2 3
Top | Discussion index | About this forum | D home