On 01/02/2018 11:17 AM, Jonathan M Davis wrote:
> On Tuesday, January 02, 2018 10:37:17 Ali Çehreli via Digitalmars-d-learn
> wrote:
>> For these reasons, the interface that the program is using is a "slice".
>> Dynamic array is a different concept owned and implemented by the GC.
>
> Except that from the standpoint of the API, T[] _is_ the dynamic array -
> just like std::vector is the dynamic array and not whatever its guts are -

I understand your point but I think it's more confusing to call it a dynamic array in the following code:

    int[42] array;
    int[] firstHalf = array[0..$/2];

I find it simpler to see it as a slice of existing elements.

In contrast, calling it a dynamic array would require explaining not to worry, no memory is being allocated; the dynamic array is backed by the stack. Not very different from calling it a slice and then explaining the GC involvement in the case of append.

> Regardless, the fact that they're a container/range hybrid is what makes
> this such a mess to understand. The semantics actually work fantastically if
> you understand them, but it sure makes understanding them annoyingly
> difficult.
>
> - Jonathan M Davis

Agreed.

Ali

Reply via email to