On Thursday, 23 April 2015 at 18:37:47 UTC, Walter Bright wrote:
On 4/23/2015 1:10 AM, bearophile wrote:
Walter Bright:
On 4/22/2015 2:58 PM, bearophile wrote:
D is less stack-friendly than Ada (and probably Rust too),
??
In Ada standard library you have safe fixed-size
stack-allocated associative
arrays. In D you can't even allocate safely a
dynamically-sized 1D array on the
stack, and forget about doing it for 2D. Enough said.
I used to use alloca() here and there, but eventually removed
it all. The trouble is, there are three array sizes:
a) 0
b) 1
c) arbitrarily large
Dynamic stack allocation works for none of them. What does work
is a fixed size stack allocation with failover to using
malloc/free, which is what Phobos' scopebuffer does. It's
analogous to the "small string optimization".
I don't agree with your assessment at all.
Is there a reason scopebuffer isn't part of the documentation?