[Gambas-user] Would an ArrayList datatype be helpful for gambas users?
T Lee Davidson
t.lee.davidson at gmail.com
Mon Sep 11 19:04:16 CEST 2023
On 9/11/23 12:10, BB wrote:
> I am not sure what extracts or removes would be capable of mucking up though. Using Lee's sample
>
> aSlice = aStrings.Slice(5,2)
> aStrings.Remove(5,2) 'Where would aSlice be pointing to now? Would it be null or an empty String[]?
>
> or
>
> aStrings.Extract(4,-1) ' Where would aSlice be pointing to now? Would it be null or an empty String[]?
In both situations, that would depend on how the particular language implements a slice under the hood.
If it holds a reference on the underlying array, ie. the array's first data element (using an offset and a length as limiters),
then any access of the slice's elements, now non-existent in the array, would be an out of bounds condition of the array.
If on the other hand, the slice holds a reference to the index /within/ the array which is specified by the slice's starting
index, then the reference would become invalid, ie. a dangling pointer. And, yes, I think the reference into the original array
must be nullified.
> I think they have to be an empty string array, but the reference into the original array must be destroyed.
--
Lee
More information about the User
mailing list