Reflection
Sean Kelly
sean at f4.ca
Thu Mar 2 11:57:47 PST 2006
Bruno Medeiros wrote:
> Bruno Medeiros wrote:
>>
>> Ok, this shows the usefulness of such feature, however there are some
>> problems/limitations. It only works with primitive types (there is no
>> isClass method of TypeInfo). For this feature to reach the full
>> potential, then the TypeInfo class would have to be extended with info
>> about the type's type, (i.e., the metatype, like struct, class,
>> function, primitive, etc.), so that one could use reflection with
>> non-primitive types, especially classes and arrays.
>>
> Strike that, we already have it. Upon further investigation I came to
> object.d where there are children classes of TypeInfo for each of the
> metatypes. Nice! :D
And there are more in std/typeinfo. The problem is that, as far as I
know, the names of these classes are not standardized, nor is the output
returned by the name method, so they're of limited direct use. For Ares
I actually moved std/typeinfo into the runtime and don't expect the
classes to be used directly, but rather for the user to do typeid(int)
or whatever to return a reference to the appropriate TypeInfo object.
Sean
More information about the Digitalmars-d
mailing list