D features

Steven Schveighoffer schveiguy at yahoo.com
Tue Sep 20 14:02:49 PDT 2011


On Tue, 20 Sep 2011 15:58:06 -0400, Rishat Galiulin  
<rishatgaliulin at mail.ru> wrote:

> I'm newbie to D, but I've been wondered by its features.

Welcome!

>
> I have some questions about D2 and its standard library :
> 1) Why is "Object.factory(string classname)" not allowing to create  
> objects without default constructor, for example:
>      ubyte[] array = new ubyte[10];
>      MyClass my = Object.factory("MyClass",  array);

D does not have a very large run time reflection capability.   
Object.factory and the TypeInfo system is pretty much it.  The theory is  
that with vastly superior compile-time reflection, the need for runtime  
reflection is either obviated or can be built using compile-time  
reflection.

I think in fact an older library (flectioned) was built using this theory,  
but I've never used it, and it probably needs some dusting.

> 2) Why D not using functions exceptions specification list like Java? If  
> this promotes bad programming style to newbies, may be better at least  
> to create compilation warnings?

Not sure what the question is, D does not support exception specification  
because exception specifications are too cumbersome to be useful.   
However, it does support saying that a function does *not* throw  
exceptions via the nothrow attribute.

-Steve


More information about the Digitalmars-d mailing list