On Sunday, 30 March 2014 at 16:26:48 UTC, Matt wrote:
On Friday, 28 March 2014 at 13:38:01 UTC, Dicebot wrote:
.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.
Thanks for the clarification, Dicebot. Does it mention those
points in the docs, because I don't remember seeing them? So we
could be looking at something closer to:
import std.string;
import std.stdio;
class Foo{
int a;
}
class Bar: Foo{
int b;
}
void main(){
Foo bar = new Bar();
writeln ("class name: " ~
bar.classinfo.name[bar.classinfo.name.lastIndexOf(".") ..
$].dup);
}
if I'm correct?
Yes. You don't need .dup though and it will be `lastIndexOf + 1`
for the start index but key idea is solid.
This is not explicitly mentioned anywhere because "runtime type
information" (http://dlang.org/phobos/object.html#.Classinfo) is
a wide-spread term with strong meaning.