Runtime reflection

Jascha Wetzel firstname at mainia.de
Thu Sep 20 02:40:16 PDT 2007


Craig Black wrote:
> Impressive!  I am surprised at how little code is required.
> 
> I remember something about traits not distinguishing between overloaded 
> functions.  Is this still the case or was this fixed in 2.004?  Are 
> there any other problems with traits that you have encountered?

__traits does distinguish overloaded functions. But it does not 
associate functions that override an inherited function with the class 
they're implemented in. That is, there appears to be no way to list all 
functions that are implemented by the given class (overridden inherited 
or not) without also listing all inherited ones. derivedMembers only 
lists non-overridden functions.

Another, maybe related thing is, that there appears to be no way to tell 
whether a function has an implementation or not. classinfoex tries to 
get the address of any function it finds in the static constructor, 
which will lead to linker errors (no body => no address).

Otherwise, __traits is fine. classinfoex isn't using __traits very 
exhaustively, though. All it does is saving a TypeInfo with the name and 
address/offset of the symbol. The rest is drawn from TypeInfos.
TypeInfo is more trouble. working around the missing parameter TIs in 
TypeInfo_Function is pretty extensive, and classinfoex is buggy there.



More information about the Digitalmars-d-announce mailing list