Dynamic array and slices (need Walter and Andrei decision)

Maxim Fomin maxim at maxim-fomin.ru
Thu May 30 11:25:07 PDT 2013


In neighbor thread (especially from 5 page 
http://forum.dlang.org/thread/mailman.175.1369540733.13711.digitalmars-d@puremagic.com?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.


More information about the Digitalmars-d mailing list