digitalmars.D - DIP8: Templating ClassInfo and TypeInfo
- dsimcha (9/9) Nov 02 2009 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP8
- Andrei Alexandrescu (4/15) Nov 02 2009 I think ClassInfo should be merged with TypeInfo. There should be no
- dsimcha (4/19) Nov 02 2009 At first glance (not having thought about it in detail) I tend to agree....
- grauzone (6/17) Nov 02 2009 I'd say it's a good idea. We have all this crap like TypeInfo.init,
http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP8 Abstract: Currently, the layout of D's runtime type info, or RTTI, is defined in object.d. The details of how the fields of each instantiation of these classes are populated are buried deep inside the compiler. If ClassInfo and TypeInfo were instead template classes inheriting from some non-templated abstract base class that defined the interface and field layout, any compile-time introspection feature could trivially be added to RTTI and made available at runtime.
Nov 02 2009
dsimcha wrote:http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP8 Abstract: Currently, the layout of D's runtime type info, or RTTI, is defined in object.d. The details of how the fields of each instantiation of these classes are populated are buried deep inside the compiler. If ClassInfo and TypeInfo were instead template classes inheriting from some non-templated abstract base class that defined the interface and field layout, any compile-time introspection feature could trivially be added to RTTI and made available at runtime.I think ClassInfo should be merged with TypeInfo. There should be no more classinfo member, only e.g. meta.typeid(type) and meta.typeid(object). Andrei
Nov 02 2009
== Quote from Andrei Alexandrescu (SeeWebsiteForEmail erdani.org)'s articledsimcha wrote:At first glance (not having thought about it in detail) I tend to agree. However, this is somewhat orthogonal to what I'm proposing. What I'm proposing has more to do with the implementation of RTTI than the interface to it.http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP8 Abstract: Currently, the layout of D's runtime type info, or RTTI, is defined in object.d. The details of how the fields of each instantiation of these classes are populated are buried deep inside the compiler. If ClassInfo and TypeInfo were instead template classes inheriting from some non-templated abstract base class that defined the interface and field layout, any compile-time introspection feature could trivially be added to RTTI and made available at runtime.I think ClassInfo should be merged with TypeInfo. There should be no more classinfo member, only e.g. meta.typeid(type) and meta.typeid(object). Andrei
Nov 02 2009
dsimcha wrote:http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP8 Abstract: Currently, the layout of D's runtime type info, or RTTI, is defined in object.d. The details of how the fields of each instantiation of these classes are populated are buried deep inside the compiler. If ClassInfo and TypeInfo were instead template classes inheriting from some non-templated abstract base class that defined the interface and field layout, any compile-time introspection feature could trivially be added to RTTI and made available at runtime.I'd say it's a good idea. We have all this crap like TypeInfo.init, TypeInfo.equals/compare/hash for which there's separate implementations for each type (like TypeInfo_f in ti_float.d; repeat for each type). With templated TypeInfos, all these could be trivially provided by the same code.
Nov 02 2009