How to get to a class initializer through introspection?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Aug 3 00:32:49 UTC 2020


On 8/2/20 6:48 PM, Stefan Koch wrote:
> On Sunday, 2 August 2020 at 22:25:19 UTC, Andrei Alexandrescu wrote:
>> I'm working on redoing typeid for classes without compiler magic, and 
>> stumbled upon the class initializer - the bytes blitted over the class 
>> before the constructor is called.
>>
>> Any ideas on how to do that via introspection? The fields are 
>> accessible, but not their default values.
>>
>> It seems like __traits(type, getInitializer) might be necessary.
> 
> So you are introducing new compiler magic in the form of __traits,
> To replace the old compiler magic in the form of type-info?
> 
> What exactly is the goal of this?

The idea is to minimize the compiler magic and shift most of the work to 
the library in an on-demand manner. Most of the typeid stuff is 
(somewhat surprisingly) moveable to library code. Moving the classinfo 
part will expose the holes in the __traits offering. Once the typeid 
stuff is in druntime, there are numerous opportunities for improving and 
extending it.


More information about the Digitalmars-d mailing list