On Friday, 28 March 2014 at 11:28:09 UTC, JR wrote:
On Thursday, 27 March 2014 at 17:41:14 UTC, Jeremy DeHaan wrote:
typeof(this) gives its fully qualified name though. I was looking for a way to get just the name of the class alone.

I guess I'm confused about what 'fully qualified name' entails.

For a class Foo, is "Foo" not just the name of the class?

          assert(typeof(this).stringof == "Foo");

I just ran the following on DMD 2.065:

---

import std.stdio;

class Foo{
        int a;
}

void main(){
        writeln ("stringof class: ", Foo.stringof);
        writeln ("classname: ", Foo.classinfo.name);
}

---

The following was the result:

---

stringof class: Foo
classname: classname.Foo

---
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.

Reply via email to