DIP 1025--Dynamic Arrays Only Shrink, Never Grow--Community Review Round 1

Suleyman sahmi.soulaimane at gmail.com
Tue Nov 12 02:02:00 UTC 2019

On Monday, 11 November 2019 at 10:27:26 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community 
> Review for DIP 1025, "Dynamic Arrays Only Shrink, Never Grow":
> [...]

I also find it a problem that dynamic arrays do not carry their 
allocator in their type, hence the problem with reallocation. It 
works for a GC only language and many people think of D like this 
and are not complaining about it, so their voice should be given 
the importance that it deserves. In addition, D also wants to 
compete in convenience with scripting languages. Clearly there is 
a good argument on both sides. A separation between a slice and 
an array which knows its allocator is needed, but the convenience 
hit is too big for those who never in their life called malloc, 
so it's hard to make a good decision on this.

In general, D has made good decisions so far regarding this 
issue. For people who just want the convenience then things are 
great, the GC is dominant, malloc is @system so they need to be 
careful with it. And for those who want to control memory 
allocation they have to use @nogc.

The problem comes when these two worlds talk to each other, the 
@nogc world and the convenience world, the medium they use is a 
slice. But I don't find it that much of a problem, since the 
convenience world will never manually allocate or free anything, 
and the @nogc world cannot assume anything about who allocated a 
slice, that's the beauty of the slice, that it's very portable.

More information about the Digitalmars-d mailing list