<div dir="ltr">On 24 May 2013 15:29, deadalnix <span dir="ltr"><<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Friday, 24 May 2013 at 05:02:33 UTC, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On 24 May 2013 14:11, Marco Leise <<a href="mailto:Marco.Leise@gmx.de" target="_blank">Marco.Leise@gmx.de</a>> wrote:<br></div><div class="im">
I don't think it's hack-ish at all, that's precisely what the stack is<br>
there for. It would be awesome for people to use alloca in places that it<br>
makes sense.<br>
Especially in cases where the function is a leaf or leaf-stem (ie, if there<br>
is no possibility of recursion), then using the stack should be encouraged.<br>
For safety, obviously phobos should do something like:<br>
  void[] buffer = bytes < reasonable_anticipated_buffer_<u></u>size ?<br>
alloca(bytes) : new void[bytes];<br>
<br>
</div></blockquote>
<br>
That is probably something that could be handled in the optimizer in many cases.<br>
</blockquote></div><br></div><div class="gmail_extra" style>The optimiser probably can't predict if the function may recurse, and as such, the amount of memory you feel is reasonable to take from the stack is hard to predict...</div>
<div class="gmail_extra" style>It could possibly do so for leaf functions only, but then most of the opportunities aren't in leaf functions. I'd say a majority of phobos allocations are created when passing strings through to library/system calls.</div>
</div>