Stack allocation of dynamic arrays?

Xinok xnknet at gmail.com
Wed Aug 8 13:35:41 PDT 2007


That would be allocated on the heap. If you want to allocate on the 
stack, use a static array:
int[5000] arr;

There's no need for the 'scope' keyword there, it's automatically 
allocated on the stack.

Robert Fraser wrote:
> I know that by using "scope" you can allocate a class on the stack rather than the heap. For this line:
> 
> scope int[] arr = new int[5000];
> 
> ... is arr allocated on the heap or on the stack?


More information about the Digitalmars-d-learn mailing list