Setting array length to 0 discards reserved allocation?

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 15 17:17:32 PDT 2014


On Mon, 11 Aug 2014 03:04:41 -0400, Andrew Godfrey <x at y.com> wrote:

> Reminder: The PR is ready for review:
>
> https://github.com/D-Programming-Language/dlang.org/pull/623
>
> Jonathan has summarized his position in the commments.
> What do the rest of you think?
> H. S. Teoh, Jakob, Ali, Marc, Dominikus, Chris -
> your impression of whether this clears up the confusion would
> help round out the feedback.

Sorry to be chiming in late on this.

As the author of the article, I stand by my terminology, even if it's not  
"official." In fact, when I was writing the article, I was struggling to  
describe how arrays worked until I stumbled into that description, and  
then it all clicked pretty well.

This issue has come up before, and I can't remember what the result was,  
but I am not severely attached to the terminology if it hurts the  
documentation of D (In other words, I'm willing to allow a pull request to  
the article on dlang's site if it is what people want). As I recall, I was  
in favor of changing the official definition (though not the advocate of  
it), but most were not. I think the definition of dynamic array as most  
languages define it, and dynamic array as D defines it, are not exactly at  
odds with each other, but the differences are significant.

What is needed is a nice term for "reference to a chunk of data." I  
thought slice fit that bill nicely, but I can see how it would be  
confusing.

The fact that slices act sort of like dynamic arrays, even though they may  
not even point at arrays at all, is a very awkward definition. It would be  
like calling all C pointers arrays.

-Steve


More information about the Digitalmars-d mailing list