digitalmars.D - Can classinfo and typeinfo_struct be templates?
- dsimcha <dsimcha yahoo.com> Nov 01 2009
I've created and submitted to Bugzilla a patch that makes heap scanning in the GC precise, provided that the GC is provided with the necessary information about pointer offsets when memory is allocated. (Bug 3643) It also includes templates for generating that information for arbitrary types at compile time. From what I understand, Walter does not want new to become a template. Currently, new receives RTTI to figure out how to perform an allocation (see lifetime.d in druntime). The pointer offset information necessary for precise heap scanning can't be generated from RTTI in its current form, only by hand or from templates. An elegant solution to this problem would be to make TypeInfo for structs and ClassInfo templates instead so that the information could easily be placed inside these classes at compile time. Right now, it appears that the way that TypeInfo and ClassInfo find out the information about the types they represent is through magic embedded in the compiler. If they were templates, it would be much easier to extend them without hacking the compiler, both for precise GC and for any other reason.
Nov 01 2009