Templatize dynamic cast. better user customized RTTI

davidl davidl at 126.com
Sun Nov 11 18:31:34 PST 2007


Dynamic cast is some thing should be templatized.

A typical call to dynamic cast, we need to push classinfo, object.

A templatized dynamic cast, we only need to push object itself.

It would make the code size smaller with a very neglectable runtime cost.

Moreover, class oriented stuff would be best if it's customized.

For porting DMDFE, a very interesting use case of class hierarchy, directly
using D's classinfo would result codebloat & bad run time efficiency.

For extreme case, we sometimes don't need a full consistent classinfo.
Sometimes we want a little bit sacrifice at runtime but cut a lot  
generated code
size. Like ForeachStatement in DMDFE, it represents ForeachStatement,
ForeachReverseStatement, if I create two class, it costs too much to only
get a different classinfo for this two classes. and mixin template would  
make
the binary bloat. So for this special case, a different dynamic cast is  
used
in DMDFE, there's a specific field to trait what kind of class this is.

I think a lot factors contribute to make dparser binary bigger than DMDFE,  
this
RTTI is one of the issue.

With traits power, and the compile-time power we now have, it's really  
possible
to leave the classinfo to user to design on their own. so RTTI would be  
flexible
and less user sensitive information would be exposed. Consider a  
commercial ware,
classinfo.name would expose their internal design of their classes in  
their binary.


-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list