Array Ambiguity

Jonathan M Davis newsgroup.d at
Thu Dec 20 23:49:00 UTC 2018

On Thursday, December 20, 2018 4:18:45 PM MST bauss via Digitalmars-d wrote:
> On Thursday, 20 December 2018 at 22:59:31 UTC, Your Name wrote:
> > Static + Dynamic arrays exhibit some really weird behavior.
> >
> >
> >
> >
> No weird behavior.
> The parameter as "int[] a" doesn't actually mean dynamic array.
> It means slice. It takes a slice of the static array.

Per the official language terminolgy, int[] is a dynamic array regardless of
what it's a slice of. And aside from lifetime issues, there really isn't a
semantic difference between a dynamic array that's a slice of GC-allocated
memory or a slice of something else (like a static array). It acts exactly
the same, including the abilility to be appended to (it's just that if it's
not GC-allocated, it's guaranteed to not be able to grow in place, whereas
with a GC-allocated array, it might be able to).

- Jonathan M Davis

More information about the Digitalmars-d mailing list