Straight Forward Arrays

dhs dhs at email.com
Wed Oct 4 10:51:46 UTC 2023


On Monday, 2 October 2023 at 02:56:33 UTC, Steven Schveighoffer 
wrote:
>
> FWIW, there is a cache that makes this decently fast, so it 
> doesn't have to go all the way into the GC to get all the 
> information for every append.
>
> But it *most definitely* not going to be as fast as reading a 
> local "capacity" variable.
>
> -Steve

Sure, I saw that, it obviously works pretty good.

I think it's worth mentioning that D slices are similar in 
concept to Go slices.

In Python, lists are reference types too but slicing creates a 
copy (so, 'b = a' shares, while 'b = a[:]' copies.) JavaScript 
arrays are similar to Python in this sense.
C++ and Rust use distinct types for the resizable array and its 
view, and the view must not outlive the array.

D and Go slices have advantages but can be confusing. I don't 
have a solution, but if anyone is interested, the relevant 
discussions about slice confusion in the Go community apply to D 
slices as well.


More information about the Digitalmars-d-learn mailing list