March 30, 2014
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?
March 30, 2014
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.
March 30, 2014
On Sunday, 30 March 2014 at 16:33:47 UTC, Dicebot wrote:
> 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.

what about .stringof? I don't think it mentions about the fact that that gets the string at compile time
March 30, 2014
On Sunday, 30 March 2014 at 16:42:54 UTC, Matt wrote:
> On Sunday, 30 March 2014 at 16:33:47 UTC, Dicebot wrote:
>> 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.
>
> what about .stringof? I don't think it mentions about the fact that that gets the string at compile time

http://dlang.org/property.html#stringof

Term such as "source representation" has no meaning for run-time, at least not for natively compiled languages.
1 2
Next ›   Last »