Thanks for the interesting and detailed explanation. :-)

> Now you see, 'new' is for dynamic memory allocation in D as well, it's
> just that for classes it is required.  You normally don't need to worry
> about 'delete', as the GC will take care of deallocation.

I guess I am worried about what could happen in the case of code like this in 
C++:

    for(i=0;i<10000;++i) {
        Foo f(i);
        // Do something with f ...
    }

... when it reappears in D as:

    foreach(uint i;0..10000) {
        auto f = new Foo(i);
        // Do something with f ...
    }

Of course, it's not so terrible to have to put an explicit 'delete' statement at
the end of the foreach loop if that is necessary (I am after all a C person at
heart:-).  It's also clear that GC will probably make such a loop more efficient
as it will manage the alloc/dealloc'ing of the memory more intelligently within
the system constraints.  But the concern is there ...

Reply via email to