Getting a class' name, but not fully qualified?

Dicebot public at dicebot.lv
Fri Mar 28 06:37:59 PDT 2014


On Friday, 28 March 2014 at 13:28:00 UTC, Matt wrote:
> I haven't tried with deeper derived trees, but this seems to
> suggest that the .stringof property provides the class name,
> WITHOUT the full qualification.

Those can't be really compared.

.stringof provides string representation of anything at 
compile-time. For class symbols it will be unqualified name of a 
symbol. Important thing is that stringifications happens only 
during compile-time and ignores polymorphism.

.classinfo name is name for actual class instance referenced from 
the variable it was applied to. It happens to be fully qualified 
but key difference here is that it uses RTTI (run-time type 
information) to access "real" type of polymorphic entity.

When working with classes you in most cases want the latter.


More information about the Digitalmars-d-learn mailing list