Setting array length to 0 discards reserved allocation?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 27 01:49:42 PDT 2014


On Sunday, 27 July 2014 at 05:51:46 UTC, Jakob Ovrum wrote:
> On Saturday, 26 July 2014 at 23:06:02 UTC, Andrew Godfrey wrote:
>> Thereafter can come sub-slice examples and so on.
>> Does this make sense?
>
> Yes, the reference documentation is pretty terrible with naming 
> of various array concepts.
>
> IIRC, when this was discussed in the past, a majority seemed to 
> be in favour of using "slice" and "dynamic array" for their 
> respective concepts instead of the current situation, but I 
> also remember there was some opposition (for reason I can't 
> remember). A pull request updating the documentation to use 
> slice/dynamic array might weed them out ;)

As defined by the language, T[] is a dynamic array. As great as 
the article is, it was wrong in its use of the terminology, and 
that's what's caused a lot of the confusion and resulted in 
arguments over the difference between a dynamic array and a slice 
(there really isn't any). IIRC, both Walter and Andrei stated in 
that discussion that T[] is a dynamic array as far as D is 
concerned and that's not going to change. The article really 
should be updated to reflect the correct terminology. As far as D 
is concerned a slice and a dynamic array are the same thing when 
it comes to arrays. They're just different names for T[], and 
trying to treat them as different just causes confusion.

- Jonathan M Davis


More information about the Digitalmars-d mailing list