On Thursday, 30 May 2013 at 18:25:08 UTC, Maxim Fomin wrote:
In neighbor thread (especially from 5 page
http://forum.dlang.org/thread/[email protected]?page=5)
there is discussion about current state of definitions in D
related to slices, slice expressions and arrays. There is
significant contradiction between documentation in different
parts of the D site and people who interpret it.
Problem boils down to following:
- in array and type official spec page, dynamic array is
defined as T[] type as "Dynamic arrays consist of a length and
a pointer to the array data.". The page also describes what
slicing is. Also expression page defines what SliceExpression
is. Internally dmd follows these conventions.
- in articles part of the site there is article "D Slices"
written by Steven Schveighoffer, which abolishes current
relevant parts of current spec. According to the article,
dynamic array is runtime managed memory which in implementation
specific manner provides some set of operation related to
arrays. According to the article T[] is by no means a dynamic
array, but a slice. The article explicitly claims that spec is
wrong.
So, there is contradiction between what T[] is. Either it is a
slice (and what is more important, not a dynamic array type)
which point by druntime managed dynamic array, or is object of
type dynamic array, which may point to heap or stack memory.
Discussion shows that there is no clear consensus on this, so
there is need for Walter and Andrei to comment on this.
An array IS a slice. A slice IS an array. Nothing contradict
anything.