-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
While trying to explain a behavior of slicing an array, and the associated resulting capacity, we realized the spec wasn't immediately clear as to whether slicing an array reuses that array. Making it hard to know if it's part of the spec, or an implementation defined detail.
While reading this section, I understood it to say that this array would be used in the slice but not everyone interpreted it that way:
A slice, once initialized, is always associated with an underlying array that holds its elements. A slice therefore shares storage with its array and with other slices of the same array; by contrast, distinct arrays always represent distinct storage.
Would you be able to clarify if the spec guarantees this behavior, or if it's implementation-specific? If the former, would it make sense to add an explicit note to the spec to clear up any confusion? If it's not guaranteed, is it worth calling that out as being implementation specific?