review delphi designation &suggestion for D
davidl
davidl at 126.com
Wed Dec 27 20:04:33 PST 2006
i've been playing with D&Delphi for a while. I've posted an article in
D.learn about
bringing DDoc property and class member's name property. I think we should
concern
this b4 1.0 is out. So i repost it here, hope walter could take notice on
this.
i think Runtime type information (RTTI in delphi) is somewhat similar to
DDoc properties
and also class members' name property.
with class members' name property we could have a full reflection &
serialization mechanism
think about
void serializer(T)(T t)
{
foreach(a;t.tupleof)
{
writefln(`serializing `~a.membername~` `~a);
}
}
with ddoc property we can find descriptions and definitions easier.
if we have ddoc designed to generate a tree like datastructure.
consider the following file:
module testddoc;
/** class **/
class myclass
{
int member; ///member1;
long member2; ///member2;
}
/** hello func**/
void hello()
{
/** nested func**/
void nestedfunc()
{
}
}
void main()
{
/// ddoc
hello();
auto myclassinstance= new myclass;
}
with ddoc property , i hope i can have
nestedfunc.ddoc -> ' nested func '
nestedfunc.ddoc.parent -> ' hello func '
myclassinstance.ddoc -> 'class'
myclassinstance.member.ddoc -> ' member1 '
myclassinstance.member.ddoc.parent -> 'class'
myclassinstance.member.ddoc.parent.parent -> 'Module testddoc'
and we can have
DDOC getTopModule(T)(T t)
{
static if ( t.parent != 0 )
return getTopModule(t.parent);
return t;
}
//a func print ddoc info
DDOC print=getTopModule(myclassinstance.member.ddoc);
while (ddocprint.child!=myclassinstance.member.ddoc)
{
writef(ddocprint.child~' ');
ddocprint= ddocprint.child;
}
i hope it would print:
Module testddoc class member1
this would be helpful for generating meaningful debug info.
This's a just a rough thinking. suggestions are welcome
--
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list