Debug help - Programming in D - extending tail slice terminates sharing unexpectedly. Page 69, 70

Brother Bill brotherbill at mail.com
Sun Oct 19 23:27:28 UTC 2025


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.

So would you recommend that when playing with slices to not 
extend the tail?

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?


More information about the Digitalmars-d-learn mailing list