Thread overview
Reflection/RTTI?
Oct 02, 2003
Mike Hearn
Oct 03, 2003
Helmut Leitner
Oct 26, 2004
LiuXuHong
October 02, 2003
Hi,

Does D support any form of reflection or RTTI? I didn't see any mention of this on the webpage.

thanks -mike
October 03, 2003
Hi

>
> Does D support any form of reflection or RTTI? I didn't see any mention of this on the webpage.
>
> thanks -mike

There's some support for it already. For any object you can allways get a ClassInfo structure and see the name of the class, wich class is it's parent and wich interfaces it implements:

import stream;

File f = File();
ClassInfo fci = ifile.classinfo;

printf("Class name: %s\n", fci.name);
printf("Base class name: %s\n", fci.base.name);

There's a pointer to the vtable, contructors, destructor and invariant methods.

What I'm missing the most is the capability to see a class' methods and read wich parameter types they need... but this seems quite difficult in a native code compiled language.

You can see the ClassInfo source in /dmd/src/phobos/object.d



October 03, 2003

"Julio César Carrascal Urquijo" wrote:
> 
> Hi
> 
> >
> > Does D support any form of reflection or RTTI? I didn't see any mention of this on the webpage.
> >
> > thanks -mike
> 
> There's some support for it already. For any object you can allways get a ClassInfo structure and see the name of the class, wich class is it's parent and wich interfaces it implements:
> 
> import stream;
> 
> File f = File();
> ClassInfo fci = ifile.classinfo;
> 
> printf("Class name: %s\n", fci.name);
> printf("Base class name: %s\n", fci.base.name);
> 
> There's a pointer to the vtable, contructors, destructor and invariant methods.
> 
> What I'm missing the most is the capability to see a class' methods and read wich parameter types they need... but this seems quite difficult in a native code compiled language.
> 
> You can see the ClassInfo source in /dmd/src/phobos/object.d

Added to
  <http://www.prowiki.org/wiki4d/wiki.cgi?FaqRoadmap>

-- 
Helmut Leitner    leitner@hls.via.at
Graz, Austria   www.hls-software.com
October 26, 2004
printf("Class name: %s\n", fci.name);
printf("Base class name: %s\n", fci.base.name);

There's a pointer to the vtable, contructors, destructor and invariant methods.

contructors is not available!!