Dynamic array and slices (need Walter and Andrei decision)

Steven Schveighoffer schveiguy at yahoo.com
Thu May 30 13:42:43 PDT 2013


On Thu, 30 May 2013 16:15:36 -0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 5/30/13 1:44 PM, Maxim Fomin wrote:
>> It would be good if Walter or Andrei comment on this.
>
> Not sure I understand the context.

(moved here from other thread)

The issue is that the spec defines T[] as a dynamic array type:

http://dlang.org/arrays.html#dynamic-arrays

While the article I wrote expresses my view of T[] as being a different  
type of beast called a slice, and specifically NOT a dynamic array  
(actually, someone pointed out quite correctly that a slice could be a  
slice of anything, and Ali came up with the term "array slice", which I  
think makes the most sense).

I found this a helpful way of explaining D slices to those who are  
befuddled by them, and some people seem to agree with that.  Whether it's  
"right" or not is really up to interpretation.  Technically, if you never  
alias a slice, it certainly behaves just like a dynamic array.

The thing that Maxim takes vehement issue with (not trying to make a  
strawman here, correct me if I'm wrong) is the idea that D's website  
contains both the spec and the article which say contradictory things.

I think the spec should be updated to reflect the article's view (or at  
least note the discrepancy), since using the term "dynamic array"  
immediately invites newbies onto shaky ground when they think it is  
completely solid "Ah yes, I know what a dynamic array is.  Hey, WTF???"

Just my opinion.  I'm perfectly fine with leaving things the way they are,  
or with removing the article if it's too controversial.

-Steve


More information about the Digitalmars-d mailing list