DIP 1025--Dynamic Arrays Only Shrink, Never Grow--Community Review Round 1
Steven Schveighoffer
schveiguy at gmail.com
Mon Nov 11 21:39:36 UTC 2019
On 11/11/19 4:32 PM, Walter Bright wrote:
> On 11/11/2019 3:17 AM, Jonathan M Davis wrote:
>> Ouch. This would be a _huge_ breaking change. The ability to grow dynamic
>> arrays is used all over the place. It's also one of the great benefits of
>> D's dynamic array IMHO. The fact that you append to a dynamic array
>> without
>> caring where it came from can be incredibly useful, and if you really
>> care
>> about checking whether it has the capacity to grow or whether it's
>> managed
>> by the GC, we have functions to check for that.
>
> While:
>
> a ~= b;
>
> would no longer be allowed,
>
> a = a ~ b;
>
> would be. Yes, it is a breaking change, but the fix for when that
> behavior is desired is pretty simple.
This is not the same. Appending has amortized cost, while concatenation
is not. Expect to have D applications which use this approach for
updating explode in runtime.
-Steve
More information about the Digitalmars-d
mailing list