www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Class.classinfo.name and Class.stringof

There are two ways to get class name as string;
Class.classinfo.name and Class.stringof.

I have tried to use class names as string for conditional codes, instead of
dynamic casts,
if- and switch-statements, associative arrays, or something.
Then I bumped into a problem.

Class.classinfo.name returns class name with full module names.
On the contrary, Class.stringof returns without module name.
They returns different string for the same class.
This means there is no way to compare class names determined in compile-time
and runtime.


A)
Make Class.classinfo to be invariant (leave object.classinfo as runtime at the
same time).
Then we are able to get same string for a class in both compile-time and
runtime.
I think this might be a better solution.

B)
Append full module names to Class.stringof.
This will cause destructive change.
May 19 2009