alloca() in D

bearophile bearophileHUGS at lycos.com
Sat Aug 6 04:10:27 PDT 2011


Mehrdad:

> - An "automatic" array-like structure entirely on the stack that starts 
> out with a capacity given by the user), and which switches to the heap 
> if it gets too big.

See (I will have to add one more answer in this enhancement request):
http://d.puremagic.com/issues/show_bug.cgi?id=5348


> - A function that can just allocate a structure easily on the stack, 
> taking care of constructors and whatnot...

This is (will be) in Phobos.


> How does this sound?

Variable-length stack-allocated arrays are very useful in a system language (if they are a little smarter than C VLA then it's better). In Ada many arrays are allocated like this, and this helps performance, also reducing the pressure on the GC.

Bye
bearophile


More information about the Digitalmars-d mailing list