Thread overview
Dynamic creation of instannce
Apr 24, 2006
maa
Apr 24, 2006
Deewiant
April 24, 2006
hello

I kust we,nt thru a lot of D documentation
D solve apparently to me a lot of what I hate In C.
But I still have a big question
can you in D write

new toto;

were toto is not a class name but a variable holding a class name
or do I have to go thru factories as usual
(except that it would be more simplle in D)

Thanks
Maa


April 24, 2006
<maa@lagraine.com> wrote in message news:e2io95$2cah$1@digitaldaemon.com...
> can you in D write
>
> new toto;
>
> were toto is not a class name but a variable holding a class name or do I have to go thru factories as usual

_What?_

Are you asking if it's possible to write

SomeclassToto;
new toto;

as a shortcut for

SomeClass toto = new SomeClass();

?

If that's what you're asking, then no, there isn't.  You can, however, write

auto toto = new SomeClass();

Which can save you a couple keystrokes.


April 24, 2006
maa@lagraine.com wrote:
> hello
> 
> I kust we,nt thru a lot of D documentation
> D solve apparently to me a lot of what I hate In C.
> But I still have a big question
> can you in D write
> 
> new toto;
> 
> were toto is not a class name but a variable holding a class name
> or do I have to go thru factories as usual
> (except that it would be more simplle in D)
> 
> Thanks
> Maa
> 
> 

If you're looking for runtime reflection, like in Java where you can do something like 'Class c = new Class("Foo")', which would be equivalent to 'Class c = new Foo()', then, no. D doesn't have a reflection API - at least not yet.