On Wednesday, 30 July 2014 at 06:11:58 UTC, Dominikus Dittes
Scherkl wrote:
On Wednesday, 30 July 2014 at 05:55:58 UTC, Jonathan M Davis
wrote:
I'm completely opposed to changing the official terminology.
Why?
What buys it, to have two terms "slice" and "dynamic array" if
they mean exactly the same thing?
Especially if we have two different things, the memory and the
reference to the memory, but both terms are only adressin the
second thing.
I would prefer to have one term meaning the one thing and the
other term meaning the other thing.
Words are changing meaning over the years, and I think it is
very instructive to use "dynamic array" to mean the memory, and
"slice" to mean the reference to the memory - as done in the
article. May be that was not the original meaning of those
terms but it is useful, instructive and unambigous, so it
should go in the official terminology. (otherwise we would need
a new, third term to describe the "other thing" that is not
directly accessible in the current language spec wording - but
we have none and it would only increase the confusion).
The "other thing" is just a block of memory managed by the GC and
which keeps track of the farthest into the block a particular
slice / dynamic array has grown. It doesn't actually act like a
dynamic array at all, because it doesn't ever grow. It's just
used by the GC to provide memory for dynamic arrays and is only
associated with a particular dynamic array until that array is
reallocated. Calling that block of memory a dynamic array would
be like calling the guts of a std::vector a dynamic array instead
calling std::vector a dynamic array. It's just the memory and
bookkeeping that backs the dynamic array.
And dynamic array and slice are already not entirely the same,
because of more general slicing operations. A dynamic array is
always a slice, but if you're talking about the language in
general and not arrays specifically, a slice could be something
else - e.g. you can slice a DList to get a range over it. It's
less common that those are referred to as slices, but they
essentially are, and you use opSlice to get them.
I'm increasingly tempted to just write up a new article that uses
the correct terminology. And if I can do that properly, then
maybe it'll help clear up the confusion.
- Jonathan M Davis