Newbie initial comments on D language - RTTI and run-time reflection
Robert Fraser
fraserofthenight at gmail.com
Wed Jan 30 02:47:41 PST 2008
Edward Diener wrote:
> But that is still only half the story. Run-time reflection in a RAD
> environment needs the ability to be able to create an object directly
> from the type of that object, and the type of an object must itself be
> instantiable as an object. This final ability is in Java, Python, .Net,
> and C++ Builder/Delphi. I can only encourage D to have this ability also.
From http://www.digitalmars.com/d/2.0/abi.html :
The class definition:
class XXXX
{
....
};
Generates the following:
* An instance of Class called ClassXXXX.
[...]
And from http://www.digitalmars.com/d/2.0/phobos/object.html :
class ClassInfo;
Runtime type information about a class. Can be retrieved for any
class type or instance by using the .classinfo property. A pointer to
this appears as the first entry in the class's vtbl[].
byte[] init;
class static initializer (init.length gives size in bytes of class)
string name;
class name
void*[] vtbl;
virtual function pointer table
Interface[] interfaces;
interfaces this class implements
ClassInfo base;
base class
static ClassInfo find(string classname);
Search all modules for ClassInfo corresponding to classname.
Returns:
null if not found
Object create();
Create instance of Object represented by 'this'.
const(MemberInfo[]) getMembers(string name);
Search for all members with the name 'name'. If name[] is null,
return all members.
More information about the Digitalmars-d
mailing list