On Sunday, 4 November 2012 at 19:42:29 UTC, Tommi wrote:
void func(T)(int n) { if (n <= 0) return;auto t = <create variable t of type T> ... func!(T)(n - 1); }If func is called with a runtime argument n, then the programmer cannot determine the most sensible way to allocate for variable t.
The reason for that being that if n is large enough and t gets always allocated on stack, then there's going to be a stack overflow. And if n is small enough so that all those t's could be allocated on stack, then allocating them on heap would just make the code slower.
