D features
Jacob Carlborg
doob at me.com
Tue Sep 20 23:44:02 PDT 2011
On 2011-09-20 21:58, Rishat Galiulin wrote:
> I'm newbie to D, but I've been wondered by its features.
>
> 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);
Have a look at:
https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L486
It lets you create a new instance from a string regardless of the
constructor, but it won't call the constructor. You might be able to use
this incomplete function:
https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L406
> 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?
>
> With best regards, Rishat Galiulin.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list