Dynamic array ot not

forkit forkit at gmail.com
Sun Jan 16 09:43:45 UTC 2022


On Sunday, 16 January 2022 at 04:58:21 UTC, Ali Çehreli wrote:
>
> I have a problem with calling type[] a dynamic array because it 
> is a slice, which may be providing access to the elements of a 
> dynamic array.
>

Yes. A more useful way of describing [] would be to say:

"[] represents a dynamic array except when it represents a slice 
- in which case it is merely shorthand for a slice that is 
referencing data stored somewhere else."

Something that still confuese me in my example then:
  mArr[] is actually a slice, and not a dynamic array. That is, my 
slice is referencing data located somewhere else. But where 
exactly is that other data located? It seems to me, I have a 
slice of data that doesn't actually exist once I have that slice.





More information about the Digitalmars-d-learn mailing list