Cleaned up C++

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 23 11:37:53 PDT 2015


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.



More information about the Digitalmars-d mailing list