On Sunday, 19 October 2025 at 23:27:28 UTC, Brother Bill wrote:
On Sunday, 19 October 2025 at 22:57:38 UTC, monkyyy wrote:
On Sunday, 19 October 2025 at 21:30:40 UTC, Brother Bill wrote:
Please guide me to best practices with slice sharing.
Treat it as a design flaw, if your project need both slice and
dynamic arrays and your causing spooky bugs, consider wrappers
for slicing that disables appending and dynamic arrays that
slicing returns explicit slices; pass dynamic arrays by ref.
So dynamic base arrays and tail slices that can grow can result
in spooky bugs.
Its the confusion of the two into one type
So would you recommend that when playing with slices to not
extend the tail?
If you extend the tail, I wouldnt call it a slice
Im not sure what you want from "tail slices" but maybe this:
```d
struct tailsilce(T){
T[]* data;
T[] me; alias me this;
this(ref T[] data_,int i=0,int j=-1){
data=&data;
me=data[i..j==-1?$:j];
}
opwhateveritiscalled("~=")(T a){
data~=a;
}
}
```
The workaround for this would be after extending the tail to
create a new dynamic array with the extended values, then add
the slices back from scratch?
They can just be colored, both views of [] work, its only the
overlap that causes problems