www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - TypeInfo request

reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
Currently the TypeInfo support for dynamic arrays is split into arrays of 
primitives and everything else. For example an array of ints has TypeInfo_Ai 
which subclasses TypeInfo while an array of strings (char[]) has 
TypeInfo_Array with a next field of type TypeInfo that has an instance of 
TypeInfo_Aa (which is the TypeInfo for a string).

As I've been messing around with std.format getting better array support 
I've noticed it would be nice to have a more consistent model. For example 
having TypeInfo_Ai subclass TypeInfo_Array with the next field set to 
TypeInfo_int would help.

Also having TypeInfo_Array and TypeInfo_AssociativeArray have foreach hooks 
would be very handy. Currently I don't want to add AA support to doFormat 
since it would require calling _aaApply and making assumptions about how 
foreach is implemented. For dynamic arrays I'm looping over the contents by 
hand since the layout isn't compiler dependent. 
Jul 23 2005
parent pragma <pragma_member pathlink.com> writes:
In article <dbucsl$12u7$1 digitaldaemon.com>, Ben Hinkle says...
Currently the TypeInfo support for dynamic arrays is split into arrays of 
primitives and everything else. For example an array of ints has TypeInfo_Ai 
which subclasses TypeInfo while an array of strings (char[]) has 
TypeInfo_Array with a next field of type TypeInfo that has an instance of 
TypeInfo_Aa (which is the TypeInfo for a string).

As I've been messing around with std.format getting better array support 
I've noticed it would be nice to have a more consistent model. For example 
having TypeInfo_Ai subclass TypeInfo_Array with the next field set to 
TypeInfo_int would help.

Also having TypeInfo_Array and TypeInfo_AssociativeArray have foreach hooks 
would be very handy. Currently I don't want to add AA support to doFormat 
since it would require calling _aaApply and making assumptions about how 
foreach is implemented. For dynamic arrays I'm looping over the contents by 
hand since the layout isn't compiler dependent. 
I'll second this. D's TypeInfo system has been great up until now, but its starting to come up short when compared to all the other improvments D has seen over the last few years. At the very least, Ben's suggestions for improvment should be taken seriously. Moreover, I also think that D should move towards a more comprehensive type system in D if any changes to TypeInfo are considered; that's something else that Ben also knows a thing or two about. ;) - EricAnderton at yahoo
Jul 25 2005