Stack-allocated arrays

Sean Kelly sean at invisibleduck.org
Wed Nov 12 12:04:15 PST 2008


Denis Koroskin wrote:
> 
> // D2
> shared scope T[] t2 = new T[size]; // Does it make any sense? Should it 
> be an error?

It makes sense.  Consider how futures work:

shared scope T[] t2 = new T[size];
auto f = new ComputeAsync(t2);
...
writefln( f.val );

Here, the computation could be done by another thread but in this 
situation we know for certain that the other thread will be done with it 
before t2 is destroyed.


Sean



More information about the Digitalmars-d mailing list