On Friday, 24 May 2013 at 05:02:33 UTC, Manu wrote:
On 24 May 2013 14:11, Marco Leise <marco.le...@gmx.de> wrote:
I don't think it's hack-ish at all, that's precisely what the
stack is
there for. It would be awesome for people to use alloca in
places that it
makes sense.
Especially in cases where the function is a leaf or leaf-stem
(ie, if there
is no possibility of recursion), then using the stack should be
encouraged.
For safety, obviously phobos should do something like:
void[] buffer = bytes < reasonable_anticipated_buffer_size ?
alloca(bytes) : new void[bytes];
That is probably something that could be handled in the optimizer
in many cases.