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

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Nov 11 22:25:17 UTC 2019


On Monday, 11 November 2019 at 22:04:17 UTC, Steven Schveighoffer 
wrote:
> In order for the DIP to guarantee the pointer of a slice is 
> still the pointer to memory to be freed, you have to *disable 
> assignment*. Do we want to do that too?
>
> It also must disable popFront, or really any operation except 
> for opIndex.

Actually, I think the example I gave was bad, since the DIP 
states that a slice is for borrowing, and then it should not be 
used for ownership. I retract it.

If a slice is a strictly borrowed view then you can have popFront 
etc, but not extending it.

This would basically be the same as C++ span with dynamic extents.


Then you would need something else for ownership of non-GC memory 
that can provide borrowed slices.

And yet again something else for write-buffer-views (e.g. a view 
on a field in a struct that should be written to, reallocation is 
bad in that situation).

So you need basically 3 different types. I think…


More information about the Digitalmars-d mailing list